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(“</dev/null ssh foreign-host ‘cat filename’”)
Now, why this makes a difference running it locally versus remotely
I’m not entirely sure, especially since I’d think that a here document
would be sent all at once even to a local process, but when I was
running it locally just by typing lines and then control-D, the line
returned was the first line typed after the ssh process had completed.