in reply to execute multiple commands over ssh (without module)

is there a way to execute multiple ssh commands on a remote host and save each command output in a different scalar without using a module?

Yes, look inside the module to see how its done

or better yet, install the module

A Guide To Installing Modules

Yes, even you can use CPAN

  • Comment on Re: execute multiple commands over ssh (without module)

Replies are listed 'Best First'.
Re^2: execute multiple commands over ssh (without module)
by dsx (Novice) on Feb 06, 2012 at 11:58 UTC

    in which module?

    i have already tried the module net::ssh:expect. but i need the script on several servers (linux 32bit, linux 64bit, solaris) on which i have not root access. so i try to keep it simple and don't use any module and especially not the net::ssh:expect module which has a dependency on IO::Tty which uses a shared library (tty.so).

      Try Net::OpenSSH, it's pure perl and doesn't require any other module (unless you want to use password authentication, in that case it also needs IO::Pty).

        Net::OpenSSH is a very nice module. but on the solaris server isn't installed OpenSSH. thats the problem.

        so now i have tested the following but it does not work. have anybody an idea?

        #!/usr/bin/perl -w use strict; use IPC::Open2; open2(*SSH_OUT, *SSH_IN, 'ssh -T localhost'); print SSH_IN "df -h"; my $df = <SSH_OUT>; print SSH_IN "du -sh"; my $du = <SSH_OUT>; print SSH_IN "exit"; print $df; print $du;