From: Daniel Martin Date: 2007-05-19T12:17:01+09:00 Subject: Re: ssh / popen / stdin weirdness "Mike Cahill" writes: > Sorry I can't figure out how to find the cause of this myself. I'm > sure there's some article somewhere I'm not finding. What's happening is that the standard input is getting read by the ssh process itself, if the standard input is ready when the ssh process is running. Try this on ServerB: (i.e. where you ran it locally and it succeeded) echo hi there | ruby abb.rb I'm betting that you won't get "hi there" being returned, because "hi there" will end up as standard input to the ssh process. To fix this, change this line: my_pipe = IO.popen("ssh foreign-host 'cat filename') into: my_pipe = IO.popen("ssh foreign-host 'cat filename' < /dev/null") Now ssh won't pull on your standard input stream. If you prefer to put the bit of input redirection at the front of the line, you can also do something like this: my_pipe = IO.popen("echo|ssh foreign-host 'cat filename'") or even this, though I think it's less portable: my_pipe = IO.popen("