Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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

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]
[Tux]: None work for me. My dead key is AltGr (right Alt)
[Tux]: And I just tested, neither do other Tk apps :) (95% of my Tk Apps is either just monitoring (no input) or input of just numbers). Something to investigate then
[choroba]: Maybe something like this?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-09-25 20:42 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (290 votes). Check out past polls.