How to use Net::SSH for piping?

Discussion in 'Ruby' started by Ilmari Heikkinen, Dec 4, 2005.

  1. 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
    Ilmari Heikkinen, Dec 4, 2005
    #1
    1. Advertising

  2. > 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.
    Ilmari Heikkinen, Dec 4, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. loial
    Replies:
    0
    Views:
    385
    loial
    Feb 3, 2009
  2. loial
    Replies:
    0
    Views:
    390
    loial
    Feb 10, 2009
  3. Tench Johnson
    Replies:
    1
    Views:
    276
    Biff Tannen
    Apr 23, 2010
  4. salamond

    net/ssh in ruby. ssh.exec fails

    salamond, Feb 17, 2011, in forum: Ruby
    Replies:
    0
    Views:
    221
    salamond
    Feb 17, 2011
  5. Replies:
    0
    Views:
    79
Loading...

Share This Page