Ask a Question related to Ruby, Design and Development.
-
Andrew Walrond #1
Help! redirecting stderr 1.6.x and 1.8 differences
I want to log stdout and stderr of a compile to a file, so I use (for
example) this simple ruby script, which works under 1.6.8 and doesn't under
1.8
---------------------------------
#!/bin/ruby -w
$stdout.reopen("my.log","w")
$stdout.sync=true
$stderr=$stdout
$stdout.puts("This from stdout")
$stderr.puts("This from stderr")
system("gcc foobar")
---------------------------------
Running with 1.6.8....
rubyx@atlas public $ ruby --version
ruby 1.6.8 (2002-12-24) [i686-linux-gnu]
rubyx@atlas public $ ./testout.rb
rubyx@atlas public $ cat my.log
This from stdout
This from stderr
gcc: foobar: No such file or directory
gcc: no input files
rubyx@atlas public $
And with 1.8.0...
rubyx@atlas public $ ruby --version
ruby 1.8.0 (2003-08-04) [i686-linux]
rubyx@atlas public $ ./testout.rb
gcc: foobar: No such file or directory
gcc: no input files
rubyx@atlas public $ cat my.log
This from stdout
This from stderr
rubyx@atlas public $
So what is the correct way to do this which will work under 1.8 but also
supports 1.6.8?
TIA
Andrew Walrond
Andrew Walrond Guest
-
closing stderr
I would like to prevent some output that is going to stderr during a call to a third party lib just during that call. My first guess was: ... -
reading STDERR
I have this command that reads logfiles.However, if the command isn't successful it gives me a standard error. my @logData= `program1 -log $data1... -
STDERR Weirdness
I have a Sun E-450 running Solaris 8. I keep getting the STDERR (standard error) messages printed out to the console monitor. I cannont understand... -
redirecting stdout/stderr on execl
consider the following code: ofstream logFile("out.txt"); streambuf *outbuf = cout.rdbuf(logFile.rdbuf()); streambuf *errbuf =... -
[How do I:] get what's in $stderr as a string?
How do I get access to what's in $stderr in the form of a string? In particular, I am using the following code require 'shell'... -
Gennady #2
Re: Help! redirecting stderr 1.6.x and 1.8 differences
I would do
$stderr.reopen $stdout
instead of
$stderr = $stdout
Gennady.
----- Original Message -----
From: "Andrew Walrond" <andrew@walrond.org>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Tuesday, August 26, 2003 11:19 AM
Subject: Help! redirecting stderr 1.6.x and 1.8 differences
under> I want to log stdout and stderr of a compile to a file, so I use (for
> example) this simple ruby script, which works under 1.6.8 and doesn't> 1.8
>
> ---------------------------------
> #!/bin/ruby -w
>
> $stdout.reopen("my.log","w")
> $stdout.sync=true
> $stderr=$stdout
>
> $stdout.puts("This from stdout")
> $stderr.puts("This from stderr")
>
> system("gcc foobar")
> ---------------------------------
>
> Running with 1.6.8....
>
> rubyx@atlas public $ ruby --version
> ruby 1.6.8 (2002-12-24) [i686-linux-gnu]
> rubyx@atlas public $ ./testout.rb
> rubyx@atlas public $ cat my.log
> This from stdout
> This from stderr
> gcc: foobar: No such file or directory
> gcc: no input files
> rubyx@atlas public $
>
> And with 1.8.0...
>
> rubyx@atlas public $ ruby --version
> ruby 1.8.0 (2003-08-04) [i686-linux]
> rubyx@atlas public $ ./testout.rb
> gcc: foobar: No such file or directory
> gcc: no input files
> rubyx@atlas public $ cat my.log
> This from stdout
> This from stderr
> rubyx@atlas public $
>
>
> So what is the correct way to do this which will work under 1.8 but also
> supports 1.6.8?
>
> TIA
> Andrew Walrond
>
>
>
Gennady Guest
-
Unregistered #3
Re: Help! redirecting stderr 1.6.x and 1.8 differences
maybe by trying: 2> grep-errors.txt
where 2 is the stderrUnregistered Guest



Reply With Quote

