in reply to Re^2: Net::OpenSSH how to stop(zap) capturing after time
in thread Net::OpenSSH how to stop(zap) capturing after time

You could probably write a more reliable wrapper in Perl, and install it on your remote servers, or use a one-liner.

Another option is to write your own time-limited capture method. Use pipe_out to launch the remote command and read from the returned pipe until the timeout expires. Closing the pipe will deliver a SIGPIPE to the remote process killing it.

Replies are listed 'Best First'.
Re^4: Net::OpenSSH how to stop(zap) capturing after time
by Anonymous Monk on Mar 22, 2011 at 20:28 UTC
    Thanks, it works
    my ($out, $pid) = $ssh->pipe_out("$cmd"); my $sel = new IO::Select($out); my $str = ""; while (1) { @ready = $sel->can_read(1); if(@ready > 0) { if(my $new = <$out>) { $str .= $new; } else { last; } } if ($ConnectionDeadline < time()) { kill 15, $pid; $str .= "\nConnection timeout\n"; last; } }