in reply to Net::SSH Woes

Make sure that you have all the dependencies installed properly.

#!/usr/bin/perl use strict; use warnings; use Net::SSH::Perl; use Net::SSH::Perl::Cipher; my $host = 'localhost.localdomain'; my $username = 'yourusername'; my $password = 'yourpassword'; my $cmd = 'perl -V'; warn "Starting SSH Services..."; my $ssh = Net::SSH::Perl->new($host, debug => 1); print "Done\n"; warn "Logging in..."; $ssh->login($username, $password); print "Done\n"; warn "Starting command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print $stdout, "\n";

Replies are listed 'Best First'.
Re^2: Net::SSH Woes
by btobin0 (Acolyte) on Feb 26, 2008 at 12:07 UTC
    How can I string commands along using this script?
    $ssh->cmd($cmd); $ssh->cmd($cmd1); or my $cmd = 'Perl -v', 'exit'; $ssh->cmd($cmd);
      #!/usr/bin/perl use strict; no warnings; use Net::SSH::Perl; use Net::SSH::Perl::Cipher; my $host = 'localhost'; my $username = 'yourusername'; my $password = 'yourpassword'; my $cmd = 'perl -V'; my $cmd2 = 'module_info -a Net::SSH::Perl'; my $cmd3 = 'perldoc Net::SSH::Perl'; my $cmd4 = 'exit'; warn "Starting SSH Services..."; my $ssh = Net::SSH::Perl->new($host, debug => 1); print "Done\n"; warn "Logging in..."; $ssh->login($username, $password); print "Done\n"; warn "Starting Command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print "Done\n"; warn "Starting 2nd Command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd2); print "Done\n"; warn "Starting 3rd Command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd3); print "Done\n"; warn "Starting 4th Command..."; my($stdout, $stderr, $exit) = $ssh->cmd($cmd4); print "Done\n";
Re^2: Net::SSH Woes
by btobin0 (Acolyte) on Feb 26, 2008 at 10:04 UTC
    This worked Great!!! Thanks for your help!