sugarboy has asked for the wisdom of the Perl Monks concerning the following question:

Am trying to run the a command on remote host using Net::SSH::Perl, which fails to return back any status. My script hangs up there. I have enabled debug logs a part of it is as follows:
remote-host$ service netbackup start
local-host: channel 2: new client-session
local-host: Requesting channel_open for channel 2.
local-host: Entering interactive session.
local-host: Sending command: service netbackup start
local-host: Requesting service exec on channel 2.
local-host: channel 2: open confirm rwindow 0 rmax 32768
local-host: input_channel_request: rtype exit-status reply 0


It did not go further from here

I could solve this problem using alarm, but wanted to check are there any other ways in Net::SSH::Perl that this can be handled?
  • Comment on Net::SSH::Perl hangs while running remote command

Replies are listed 'Best First'.
Re: Net::SSH::Perl hangs while running remote command
by atcroft (Abbot) on Mar 04, 2011 at 05:47 UTC

    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:

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

    Hope that helps. (And if you find an answer that helps, I'd love to see it as an update or reply.)

      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.
Re: Net::SSH::Perl hangs while running remote command
by salva (Canon) on Mar 04, 2011 at 10:11 UTC
    What happens when you manually open a session via SSH and run the same command there?