Redirecting stdout from within a Ruby script

I have a script which has been running just fine, and uses stdout to print its data.

Now I want to (optionally) send the data to another program (/bin/mail) instead of STDOUT. Can I do this programmatically within the script?

David Douthitt
CUNA & Affiliates
UNIX Systems Administrator
LPI Level 1, Linux+
ddouthitt@cuna.coop

Hi,

···

At Thu, 29 Jan 2004 09:06:41 +0900, David Douthitt wrote:

Now I want to (optionally) send the data to another program
(/bin/mail) instead of STDOUT. Can I do this
programmatically within the script?

STDOUT.reopen(IO.popen("/bin/mail #{ENV[‘USER’]}", “w”))


Nobu Nakada