Forum: Ruby How to use Net::SSH for piping?

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.
ilmari.heikkinen (Guest)
on 2005-12-04 16:04
(Received via mailing list)
Hi, I've got a bit of a problem here.

Here's the setup, I'm proxying a remote command through a unix socket:
1. Started an SSH session to a remote host using Net::SSH
2. Created an UNIXServer and now am accepting connections
3. A new connection arrives
4. Want to pipe the connection's out to a remote commands' in, and vice
versa
   Preferably using a new SSH channel and not a whole session.

E.g. the remote command would be `lame - -`, encoding wav files to mp3,
and then I would pipe a wav to the proxy and get an mp3 out like this:
`socat - UNIX-CONNECT:local_socket < my.wav > my.mp3`

What's the correct way to do the piping to the command and back with
Net::SSH?

Thanks in advance,
Ilmari
ilmari.heikkinen (Guest)
on 2005-12-04 18:48
(Received via mailing list)
> Here's the setup, I'm proxying a remote command through a unix socket:
> 1. Started an SSH session to a remote host using Net::SSH
> 2. Created an UNIXServer and now am accepting connections
> 3. A new connection arrives
> 4. Want to pipe the connection's out to a remote commands' in, and vice
> versa
>    Preferably using a new SSH channel and not a whole session.

I went with using IO.popen("ssh #{host}
#{create_proxy_script_for(filename)}")
for now, couldn't figure out how to do it with Net::SSH
(session.process.popen3 lacked .close_write, and trying to send data
in a blocking fashion with process.open took too much hacking of the
library internals (and I couldn't get it working in the end))

Oh well. It's slow and cumbersome, but at least it works in the
interim. Need to figure out a better way at some point.
This topic is locked and can not be replied to.