From: nobu.nokada@... Date: 2002-06-12T10:31:46+09:00 Subject: Re: catching error message Hi, At Wed, 12 Jun 2002 07:19:49 +0900, Tobias Reif wrote: > open('error_log.txt','w') do |file| > file.write `domcount foo.xhtml` > end > > ; error_log.txt is then > > "Errors occured, no output available". > > , and all the errors are printed to the console. How to write the > errors to the file? def redirect2(output, error, *commands) if output saved_out = STDOUT.dup STDOUT.reopen(output) end if error saved_err = STDOUT.dup STDERR.reopen(error) end system *commands ensure STDERR.reopen(saved_err) if error STDOUT.reopen(saved_out) if output end open('error_log.txt','w') do |file| redirect2(file, file, "domcount", "foo.xhtml") end -- Nobu Nakada