in reply to Re^2: Printing Output From Net::SSH2 exec
in thread Printing Output From Net::SSH2 exec
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";
|
|---|