From: Harold Hausman Date: 2007-02-23T10:12:10+09:00 Subject: Re: IO.popen on Windows to filter stdout On 2/22/07, ara.t.howard@noaa.gov wrote: > On Thu, 22 Feb 2007, Harold Hausman wrote: > > > > > > > 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? > > probably the other process is writing to stderr. try > > IO.popen( 'cmd 2>&1' ) do |pipe| > pipe.each do |line| > p line > end > end > Hi Ara, thanks for taking the time to try and help me. What you're saying about stderr here sounds right to me, but I tried what you have above, and I'm still seeing the output I'm trying to 'squash' (read: block) ... Here is my code: ######################### puts "ruby-link in the house!" the_cmd = "old-Link.exe " ARGV.each do |arg| the_cmd << "\"#{arg}\" " end the_cmd << "2>&1" puts "Calling: #{the_cmd}" IO.popen( the_cmd ) ######################### And here is the output that I see: (apologies for badly wrapped lines) ruby-link in the house! Calling: old-Link.exe "@C:\long\path\to\some.rsp" "/NOLOGO" "/ERRORREPORT:PROMPT" 2>&1 OLD-LINK : ------ So yeah, the output from old-Link.exe is still being filtered up to the top and seen. What I'm looking for is a way to shut it up... ;) > alternatively, you may want to use systemu > > http://codeforpeople.com/lib/ruby/systemu > I looked at systemu and it's not clear how it would help with this problem. :| Apologies if I'm being dense. > it's __very__ easy to block a process using IO.popen on windows. > I thought so too. ;) Thanks again for your time, -Harold