How to use Net::SSH for piping?

  • Thread starter Ilmari Heikkinen
  • Start date
I

Ilmari Heikkinen

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 ver=
sa
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::S=
SH?

Thanks in advance,
Ilmari
 
I

Ilmari Heikkinen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top