in reply to Re: Printing Output From Net::SSH2 exec
in thread Printing Output From Net::SSH2 exec

I hadn't seen that module. I will give it a try. I see it does it's business by running the openssh binary as well, but the multiplexing approach looks a lot nicer than the mess I've inherited.

Thanks!

  • Comment on Re^2: Printing Output From Net::SSH2 exec

Replies are listed 'Best First'.
Re^3: Printing Output From Net::SSH2 exec
by salva (Canon) on May 14, 2009 at 11:20 UTC
    BTW, this is how you read from both stderr and stdout:
    use Net::OpenSSH; my $ssh = Net::OpenSSH->new($host, ...); $ssh->error and die "connection failed: " . $ssh->error; my (undef, $ofh, $efh, $pid) = $ssh->open_ex({ stdout_pipe => 1, stderr_pipe => 1 }, @cmd) or die "ssh command failed: " . $ssh->error; while(1) { # select loop to read from $ofh and $efh without blocking # ... } waitpid($pid, 0); print "result: $?\n";