>
> 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:
> #########################
> <snip code>
> #########################
>
hrrrm. this is a windozing type thing, but is it perhaps manipulating the
console directly? for instance, in unix, this can happen.
I believe that the underlying executable that I'm dealing with, namely
VC8's "link.exe" is doing something very dastardly.
it's hard to say without seeing your code, and the old code, but you could try
this to prove to yourself that stdout and stderr can be diverted:
require 'tempfile'
tmp = Tempfile.new Process.pid
puts tmp.path
cmd = "put the exact command here"
STDOUT.reopen tmp.path
STDERR.reopen tmp.path
exec cmd
When I integrate the above code, a tempfile is indeed created, but it
remains empty. And what's more? I *still* see the output in the
console! (:
However, the following irb session indeed proves that stdout can be
redirected. (as well as makes me laugh out loud)
irb(main):001:0> require 'tempfile'
=> true
irb(main):002:0> tmp = Tempfile.new Process.pid
=> #<File:C:/DOCUME~1/Harold/LOCALS~1/Temp/484.484.0>
irb(main):003:0> STDOUT.reopen tmp.path
...
#hrhrhr.
harp:~ > cat a.rb
require 'systemu'
class Filter
def initialize prefix, io
@prefix = prefix
@io = io
end
def << line
@io << "#{ @prefix }: #{ line }"
end
end
o = Filter.new 'stdout', STDOUT
e = Filter.new 'stderr', STDERR
systemu 'ruby -e"STDOUT.puts 42; STDERR.puts 42"', :stdout => o, :stderr => e
harp:~ > ruby a.rb
stdout: 42
stderr: 42
This code is also awesome, but when I integrate it into my tool, it
has literally no effect on the outcome.
All of this is leading me to believe that VC8's link.exe (or as I've
renamed it 'old-Link.exe') is doing something very tricky, not
involving stdout or stderr at all.
Moreover, I've exceeded the point where solving this problem will save
me time versus watching 200k of spewed linker warnings with each build
of my software. (of course due to a 3rd party library that wont give
me their .pdb files, and a bug in VC8 which causes /IGNORE: to be
*itself* ignored on the command line of the linker.)
Oh well, thanks again for the lessons, I know more about spawning
processes from Ruby on Windows than I ever thought I would.
Regards,
-Harold
···
On 2/23/07, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
On Fri, 23 Feb 2007, Harold Hausman wrote: