# Net::SSH calls hanging

**URL:** <https://www.ruby-forum.com/t/net-ssh-calls-hanging/162425>\
**Category:** Ruby\
**Created:** [March 9, 2009, 9:17pm UTC](https://www.ruby-forum.com/t/net-ssh-calls-hanging/162425 "2009-03-09T21:17:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [March 9, 2009, 9:17pm UTC](https://www.ruby-forum.com/t/net-ssh-calls-hanging/162425/1 "2009-03-09T21:17:34Z")

</div>

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  
☹

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [March 10, 2009, 9:36pm UTC](https://www.ruby-forum.com/t/net-ssh-calls-hanging/162425/2 "2009-03-10T21:36:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![john-anes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/22d042/32.png) [@john-anes](https://www.ruby-forum.com/u/john-anes)\
**Post date:** [March 17, 2009, 1:51pm UTC](https://www.ruby-forum.com/t/net-ssh-calls-hanging/162425/3 "2009-03-17T13:51:15Z")

</div>

On Mar 10, 9:34 pm, John A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 &”
