Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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

by atcroft (Abbot)
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.)

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://891366]
[Corion]: Ouch. I just learned something about Chrome - the "version numbers" are not really feature numbers... Chrome 62 still gets new features even though Chrome 64 is out and Chrome 65 is the dev version
[erix]: why ouch? Something to be said for that ,surely?
LanX is a dev version
[marto]: That reminds me, I made some notes somewhere with regard W::M::C, I'll get round to a PR when I've time to flesh it out
[Corion]: erix: But that makes for fun bug hunting. "What version of Chrome are you running?" "v62". "I also run v62 and it works on my machine". :-(
[Corion]: marto: Great, looking forward to the PR!

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-12-12 20:13 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (335 votes). Check out past polls.