Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Net::SSH::Perl hangs while running remote command

by atcroft (Monsignor)
on Mar 04, 2011 at 05:47 UTC ( #891366=note: print w/ replies, xml ) Need Help??


in reply to Net::SSH::Perl hangs while running remote command

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.)


Comment on Re: Net::SSH::Perl hangs while running remote command
Select or Download Code
Re^2: Net::SSH::Perl hangs while running remote command
by sugarboy (Beadle) on Mar 07, 2011 at 00:16 UTC
    I tried by providing timeout option while creating ssh object, but which is not much of help...SSH is not timing out the command, its just waiting for the command to respond. Moreover am running the command in eval block.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://891366]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (13)
As of 2014-12-19 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (83 votes), past polls