From: Brian Candler Date: 2009-05-22T16:35:15+09:00 Subject: Re: I want to redirect stderr to StringIO. Robert Klemme wrote: > Please do not let yourself be distracted by the warning. The crucial > point is that after $defout has been reassigned the "2" does not appear > any more on the screen => this is the object which is used by #puts. Just do what the warning says, and use $stdout instead of $defout: $ ruby -r stringio -e 'puts 1; $stdout=StringIO.new; puts 2' 1 $ However this doesn't help the OP who wanted to redirect STDERR. You can redirect $stderr, but lots of code writes to STDERR instead of $stderr. -- Posted via http://www.ruby-forum.com/.