J
Johannes Barre
Hi list!
I'm new to ruby, so be nice to me
I want to capture everything written to the strout and get it in a
variable. So I did this:
stdout = $stdout
stdoutin, $stdout = IO.pipe
puts "Hello World"
tmp = $stdout
$stdout = stdout
$tmp.close
variable = stdoutin.readlines.join("\n")
It works, but if I write to much, the pipe seems to be full and the
script hangs. It will never continue, because I start reading from the
pipe when everthing is written. My idea is to start two theads, one for
writing and one for reading, but maybe somebody knows a easier way.
Please help!
Johannes
I'm new to ruby, so be nice to me
I want to capture everything written to the strout and get it in a
variable. So I did this:
stdout = $stdout
stdoutin, $stdout = IO.pipe
puts "Hello World"
tmp = $stdout
$stdout = stdout
$tmp.close
variable = stdoutin.readlines.join("\n")
It works, but if I write to much, the pipe seems to be full and the
script hangs. It will never continue, because I start reading from the
pipe when everthing is written. My idea is to start two theads, one for
writing and one for reading, but maybe somebody knows a easier way.
Please help!
Johannes