My first question would be what happens if you try to connect to the same host with a command-line SSH client?
I've recently started using Net::SSH::Perl myself (so I'm no expert), but you might try setting one or more of the following options when creating the object:
options => [ q{BatchMode yes}, q{ConnectTimeout } . $connect_timeout_in_sec, q{TCPKeepAlive yes}, ],
Also, you might try wrapping your $ssh->cmd() call in an eval() and checking to see if it completes successfully or not (perhaps similar to the following):
eval { ( $stdout, $stderr, $exit ) = $ssh->cmd($cmd); }; if ($@) { # Do something as a result }
Hope that helps. (And if you find an answer that helps, I'd love to see it as an update or reply.)
In reply to Re: Net::SSH::Perl hangs while running remote command
by atcroft
in thread Net::SSH::Perl hangs while running remote command
by sugarboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |