in reply to Net::SSH2 Command Timeout Before Completion

If you have a recent version of OpenSSH installed on the machine where you want to run the script, try Net::OpenSSH:
use Net::OpenSSH; my $ssh = Net::OpenSSH->new('root@192.168.123.5'); $ssh->error and die "unable to connect to remote host: ". $ssh->error; my $fh = $ssh->pipe_out("/sbin/service", "syslog", "restart") or die "command failed: " . $ssh->error; print while <$fh>; close $fh or die "command failed: $?";

Replies are listed 'Best First'.
Re^2: Net::SSH2 Command Timeout Before Completion
by taim (Initiate) on Jun 29, 2010 at 23:57 UTC

    Another one I will look at. OpenSSH is my client/server of choice.

      Another one I will look at. OpenSSH is my client/server of choice.

      For what it's worth, Net::SSH::Expect lets you choose what ssh binary to use, so if you have openssh installed separately, it can be told to use that. Not trying to be a fanboy, just letting you know.
        I appreciate the information. What I gathered from testing both is that Net::SSH2 is not the best solution. Both of your examples worked the way I wanted.