Guys, how are you?
I was googling about "redirecting $stdout and $stderr" and founded
this:
$stdout.puts "stdout"
$stderr.puts "stderr"
Then in the comand line you invoke the above snippet, lets suppose that
is called test.rb
ruby test.rb > stdout 2> stderr
What that makes is create 2 files in the current directory, one called
stdout and the other stderr, both have writed what's supposed to be in
each one. This work, but I've never seen that kind of "commands options"
or "commands arguments" and neither appears in the commons reference
ruby books, anybody knows what ">" and the rest means when invoking
test.rb?
I don't know where you're headed with this, but this is what I use to
create a logfile when I'm not running from a console:
begin
#Output log
orig_std_out = STDOUT.clone #Make a record of the default console output
to return to it later
$stdout.reopen("Rubylog.txt", "w") #Create / overwrite logfile
$stdout.sync = true #Allow interception of console output
$stderr.reopen($stdout) #Pass errorserrors to logfile
Jam, well explained. The web page that you gives is very helpfull. I
suppose that 2> reference the stderr, since is a standard that the file
descriptor of stderr is 2 in every program.
Joel, I will consider your example to implement it in some way.