Forum: Ruby Net::SSH calls hanging

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
69a4f9b96787bdbfd61c845226e48a50?d=identicon&s=25 John Allen (john_exonets)
on 2009-03-09 21:17

I'm trying to launch a server remotely, but all the Net:SSH calls I try
never seem to return...they just hang.

My Code:

cmd = "nohup ./Servers/ &"

Net::SSH.start(host[:ip], host[:user], :password => host[:passwd]) do
  rc = ssh.exec(cmd)


  rc = ssh.exec!(cmd)


   ssh.open_channel do |ch|
    ch.exec(cmd) do |cc, success|
      abort "Could not run program" unless success

      cc.on_data do |dd, data|
        puts "STDOUT>>#{data}"

      cc.on_extended_data do |ch, type, data|
       puts "STDERR>>#{data}"

      cc.on_eof do |ch|
        puts "EOF>>"

      cc.on_close do |ch|
        puts "Channel is Closing!"


All of these never return from the exec call.  I am using Net::SSH v2.

I am running the program from my PC to a large HP/UX host. The
'' program starts and is running...but my local ruby
program never returns. The 'Timeout' options doesn't seem to be working
either, as it will sit overnight, never returning.  It looks like its
locked up.

Is there some special way to start a background process using SSH??
I've tried using another perl script to start the other one, but still
get a hung exec. ..getting ready to pull what little hair is left, out
69a4f9b96787bdbfd61c845226e48a50?d=identicon&s=25 John Allen (john_exonets)
on 2009-03-10 21:36
Upgraded to Net::SSH v2.0.11 ... still have the same problem :(
9058add0b387a629a442cdc6a241add4?d=identicon&s=25 lyrics (Guest)
on 2009-03-17 13:51
(Received via mailing list)
On Mar 10, 9:34 pm, John Allen <> wrote:
> Upgraded to Net::SSH v2.0.11 ... still have the same problem :(
> --
> Posted via

I had the same problem.
Make sure your perl script isn't using stdin/stderr/stdout.

try :
cmd = "nohup ./Servers/ 2>&1 1>/dev/null 0>/dev/null &"
This topic is locked and can not be replied to.