IO redirection

  • Thread starter Daniel Brumbaugh Keeney
  • Start date
D

Daniel Brumbaugh Keeney

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
:in `reopen': uninitialized stream (IOError)

Any ideas?

Daniel Brumbaugh Keeney
 
Y

Yu-raku-an

Hi,

Use

p exec('echo', '1')

instead of
exec('echo', '1')

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

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top