Net::SSH calls hanging


#1

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


#2

Upgraded to Net::SSH v2.0.11 … still have the same problem :frowning:


#3

On Mar 10, 9:34 pm, John A. removed_email_address@domain.invalid wrote:

Upgraded to Net::SSH v2.0.11 … still have the same problem :frowning:

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 &”