From: Shashank Date Date: 2002-12-19T14:14:31+09:00 Subject: Re: automating script for a command line utility Per nobu's suggestion, this is what I did: check = IO.popen("ruby c:/ruby/bin/irb.rb",'w+') check.puts("STDOUT.sync = true") check.puts("puts $:") check.readlines.each { |line| puts line unless line =~ 'nil' } check.close_write check.readlines.each { |line| puts line unless line =~ 'nil' } But the program seemed to hang. So I killed it (using CTRL+Break in TextPad) and I got this: Interrupted! and after a couple of minutes ... C:/ruby/lib/ruby/1.7/irb.rb:234:in `write': Invalid argument (Errno::EINVAL) from C:/ruby/lib/ruby/1.7/irb.rb:234:in `print' from C:/ruby/lib/ruby/1.7/irb.rb:234:in `signal_handle' from C:/ruby/lib/ruby/1.7/irb.rb:66:in `start' from C:/ruby/lib/ruby/1.7/irb.rb:65:in `call' from C:/ruby/lib/ruby/1.7/irb/input-method.rb:49:in `gets' from C:/ruby/lib/ruby/1.7/irb/input-method.rb:49:in `gets' from C:/ruby/lib/ruby/1.7/irb.rb:130:in `eval_input' from C:/ruby/lib/ruby/1.7/irb.rb:129:in `signal_status' ... 14 levels... from C:/ruby/lib/ruby/1.7/irb.rb:70:in `start' from C:/ruby/lib/ruby/1.7/irb.rb:69:in `catch' from C:/ruby/lib/ruby/1.7/irb.rb:69:in `start' from c:/ruby/bin/irb.rb:13 Tool completed with exit code 4 Please help. Thanks very much ! -- shanko wrote in message news:200212190443.gBJ4hLb24230@sharui.nakada.kanuma.tochigi.jp... > Hi, > > At Thu, 19 Dec 2002 13:14:07 +0900, > Shashank Date wrote: > > Is there a way to check.puts each command and then immediately read the > > lines of output ? > > Try to send "STDOUT.sync = true" line first. This is because > the child process buffers stdout. In many UNIX, using pseudo > TTY tells processes to not buffer output, but Windows has no > this feature or similar. > > I remember I wrote about this, regarding cygwin and DOS prompt > issue. > > > I think IO#popen3 might do this, but it is not available on Windows. > > Correct, but impossible as OS doesn't support it. > > -- > Nobu Nakada >