Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > IO redirection

Reply
Thread Tools

IO redirection

 
 
Daniel Brumbaugh Keeney
Guest
Posts: n/a
 
      01-15-2008
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

 
Reply With Quote
 
 
 
 
Yu-raku-an
Guest
Posts: n/a
 
      01-15-2008
Hi,

Use

p exec('echo', '1')

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

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

Thank you.


Daniel Brumbaugh Keeney wrote:
> 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
>
>
>


--------------------------------------
Easy + Joy + Powerful = Yahoo! Bookmarks x Toolbar
http://pr.mail.yahoo.co.jp/toolbar/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirection Limit John Firefox 4 07-28-2005 10:47 AM
webcrawle with LWP: how to make redirection work? S Perl 1 01-14-2004 06:51 AM
input redirection MadHatter Perl 6 10-16-2003 04:05 PM
Re: Cisco PIX 6.31 Port Redirection - Not Working Memnoch Cisco 0 07-17-2003 05:22 PM
wccp 3550emi and Cacheflow 800 - transparent caching redirection news.tm.net.my Cisco 0 07-17-2003 02:48 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57