Having trouble reading from stderr
- From: Christopher Rasch <crasch@xxxxxxxxx>
- Date: Mon, 25 Feb 2008 19:49:34 -0500
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
.
- Follow-Ups:
- Re: Having trouble reading from stderr
- From: switheyw
- Re: Having trouble reading from stderr
- From: Arlen Cuss
- Re: Having trouble reading from stderr
- Prev by Date: Ruby sans Rails job
- Next by Date: how does ruby...
- Previous by thread: Ruby sans Rails job
- Next by thread: Re: Having trouble reading from stderr
- Index(es):
Relevant Pages
|