Having trouble reading from stderr



Hi,

I'm trying to write a script that will establish an ssh tunnel through
"gatewaymachine.com" to a "targetmachine" on the other side. Sometimes
there's already a tunnel established on the same port, in which case,
the command fails with an error message.

I'd like to be able to read the error message from the script. If the
script failed due to an incorrect port number, I'd like increment the
port number and try again.

Based on my google search, the popen3 command from the open3 library is
what I want to use.

But when I try to read from stderr, the read command never returns.
Here's the code:



require 'open3'

stdin, stdout, stderr = Open3.popen3("ssh crasch@xxxxxxxxxxxxxxxxxx -i
/Users/crasch/.ssh/id_rsa.pub -L 2222:targetmachine:22 -N")

puts stderr.read <---hangs indefinitely here


Any suggestions for what might be happening? Thanks for any suggestions
you may wish to provide.

Chris

.



Relevant Pages

  • Re: Having trouble reading from stderr
    ... I'm trying to write a script that will establish an ssh tunnel through ... there's already a tunnel established on the same port, in which case, ... I'd like to be able to read the error message from the script. ... the popen3 command from the open3 library is ...
    (comp.lang.ruby)
  • su - user variable problem
    ... I am writing a bash script to create users, and then generate an rsa ... The users run an app that requires an ssh tunnel, ... command does work if run directly from the command line if I use a ...
    (comp.unix.shell)
  • Re: Netstat Problem on solaris 5.8
    ... the entry for that port number in /etc/services ... and we made the the changes in our script and now it works well. ... we used the following command in shell script: ... The output of netstat on solaris is creating a problem for us ...
    (comp.unix.solaris)
  • Re: mail to exchange from unix
    ... port 25 on the other system and type in the commands if you'd like or script it etc. ... I remember some command line where sendmail is invoked as a command, ... sendmail specific testing and this sort of thing should be posted in the sendmail group. ...
    (comp.unix.shell)
  • Re: Problems trying to configure Linux laptop to print to Windows XP shared printer
    ... map to guest = Never ... check password script = ... enumports command = ... ldap delete dn = No ...
    (comp.os.linux.setup)