Forum: Ruby Net::SSH calls hanging

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

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/BARKSproxy.pl &"

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

        or

  rc = ssh.exec!(cmd)

        or

   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}"
      end

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

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

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

   end
  end
  ssh.loop
end

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
'BARKSproxy.pl' 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 <john.al...@exonets.com> wrote:
> Upgraded to Net::SSH v2.0.11 ... still have the same problem :(
> --
> Posted viahttp://www.ruby-forum.com/.

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

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