IO redirection

Basically, I need to redirect the results of exec. While I can
$stdout.reopen(file), and I can redefine $stdout to anything with a
write' method, I seem to be unable to send the results of exec to anything within my script (so exec('echo','1') would send "1\n" to a method). I tried to subclass IO, but then I get :inreopen’: uninitialized stream (IOError)

Any ideas?

Daniel Brumbaugh K.



p exec(‘echo’, ‘1’)

instead of
exec(‘echo’, ‘1’)

And you will get ‘1\n’ in the specified file.

Thank you.