D
Dario Linsky
Hi,
I am trying to open an external process that normally reads and writes from
stdin/to stdout. For opening a pipe to this process I am using IO.popen.
Reading each line from the pipe is no problem until it comes to a point where
the external process wants to get some data from stdin and it waits for input.
Now when I write something into the IO stream I need to call IO#close_write for
further reading. But since the pipe is closed now, I cannot write to it any
more.
For example:
-- snip --
pipe = IO.popen("ruby -r debug script.rb", "w+")
if pipe
while line = pipe.gets
line.chomp!
puts line
if line =~ /^script\.rb:\d+\:.+$/ # Regexp to find special lines
# Here I want to tell the debugger what to do and
# get further output to evaluate.
pipe.puts "next"
pipe.close_write
end
end
-- snap --
Is there any way to reopen the pipe at the position where I close it or is there
any way to avoid using IO#close_write so I can write more commands to the
debugger?
Greetings, Dario
I am trying to open an external process that normally reads and writes from
stdin/to stdout. For opening a pipe to this process I am using IO.popen.
Reading each line from the pipe is no problem until it comes to a point where
the external process wants to get some data from stdin and it waits for input.
Now when I write something into the IO stream I need to call IO#close_write for
further reading. But since the pipe is closed now, I cannot write to it any
more.
For example:
-- snip --
pipe = IO.popen("ruby -r debug script.rb", "w+")
if pipe
while line = pipe.gets
line.chomp!
puts line
if line =~ /^script\.rb:\d+\:.+$/ # Regexp to find special lines
# Here I want to tell the debugger what to do and
# get further output to evaluate.
pipe.puts "next"
pipe.close_write
end
end
-- snap --
Is there any way to reopen the pipe at the position where I close it or is there
any way to avoid using IO#close_write so I can write more commands to the
debugger?
Greetings, Dario