in reply to Net::SSH2 to capture multiple commands on remote system
$chan->shell(); print $chan "$cmd1\n"; @out1 = <$chan>; print $chan "$cmd2\n"; @out2 = <$chan>; ...
Unfortunately, Net::SSH2 is full of quirks and using it in the way you are doing is unreliable. You can see it if you run some slow commands, for instance, try $cmd1 = sleep 2.
If you are on a Linux/Unix system, your better option would be to switch to Net::OpenSSH.
Otherwise, you can use Net::SSH::Any which is able to run over Net::SSH2 and provides a friendlier interface while taking care of the ugly details for you... well, mostly, because there are several bugs on the current stable version of libssh2 that can not be worked around.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Net::SSH2 to capture multiple commands on remote system
by bellis (Initiate) on Sep 17, 2014 at 04:47 UTC | |
by salva (Canon) on Sep 17, 2014 at 07:27 UTC |