IO redirection

Discussion in 'Ruby' started by Daniel Brumbaugh Keeney, Jan 15, 2008.

  1. 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
    Daniel Brumbaugh Keeney, Jan 15, 2008
    #1
    1. Advertising

  2. Daniel Brumbaugh Keeney

    Yu-raku-an Guest

    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/
    Yu-raku-an, Jan 15, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MadHatter

    input redirection

    MadHatter, Oct 14, 2003, in forum: Perl
    Replies:
    6
    Views:
    693
    MadHatter
    Oct 16, 2003
  2. S
    Replies:
    1
    Views:
    814
  3. Matt
    Replies:
    0
    Views:
    306
  4. headware

    controlling redirection within frames

    headware, Aug 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    330
    headware
    Aug 5, 2003
  5. Ravikanth[MVP]

    Redirection pronblem

    Ravikanth[MVP], Aug 11, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    314
    Platino
    Aug 11, 2003
Loading...

Share This Page