From: Robert Gleeson Date: 2009-12-11T17:09:00+09:00 Subject: Re: Redirecting standard output > Yup, you can use IO#reopen too. I don't know about being "deprecated". > > $stdout.reopen will also redirect STDOUT to the location referenced in > your call to #reopen. How can you redirect $stdout to its original > location now? > > The above solution ensures you can easily switch back. Answer to my own question: FOO_BAR = STDOUT.dup $stdout.reopen '/foo/bar/baz', 'w' puts 'foobar' $stdout.reopen FOO_BAR This method might be more useful if you want to redirect both $stdout, and STDOUT. -- Posted via http://www.ruby-forum.com/.