From: ara.t.howard@... Date: 2007-02-23T00:22:20+09:00 Subject: Re: IO.popen on Windows to filter stdout On Thu, 22 Feb 2007, Harold Hausman wrote: > Hello all, > > I've been googling and playing with this for a while, but I'm stuck and I > figured I'd ask in case anyone's done this before. > > I'd like to use IO.popen, or something similar, to 'filter' the spew coming > from another programs stdout. I think I understand that I can capture the > stdout stream returned by IO.popen by using .readlines, etc... But it still > seems that the sub process is writing the output directly to $stdout... > > Of course, this is on windows, so I don't have proper fork, etc... > > Is there a way to somehow "swallow" the stdout from the sub process so it > doesn't make it directly to the ruby process' stdout? > > Thanks in advance for any insight, > -Harold > probably the other process is writing to stderr. try IO.popen( 'cmd 2>&1' ) do |pipe| pipe.each do |line| p line end end alternatively, you may want to use systemu http://codeforpeople.com/lib/ruby/systemu it's __very__ easy to block a process using IO.popen on windows. regards. -a -- be kind whenever possible... it is always possible. - the dalai lama