STDOUT redirection

Discussion in 'Perl Misc' started by paraagv@gmail.com, Apr 25, 2007.

  1. Guest

    Hi have a perl application in on suse64 bit OS, which internally
    redirects STDOUT to a $variable
    using
    This redirects STDOUT to a variable

    open OUT ,'>',\$variable
    *STDOUT = *OUT

    Now when run the tool
    e.g ./app <test>.txt > out.txt

    The application has two parts
    1. returns all text data in the <test> input as is to STDOUT
    2. returns function call with return values also to STDOUT

    Now what happens is that category 1 collects in out.txt
    while category 2 collects in the $variable

    my question is why does STDOUT get split into 2 places and how can I
    avoid it - I want all to goto the variable

    Thanks
    Paraag
     
    , Apr 25, 2007
    #1
    1. Advertising

  2. Guest

    wrote:
    > Hi have a perl application in on suse64 bit OS, which internally
    > redirects STDOUT to a $variable
    > using
    > This redirects STDOUT to a variable
    >
    > open OUT ,'>',\$variable
    > *STDOUT = *OUT
    >
    > Now when run the tool
    > e.g ./app <test>.txt > out.txt
    >
    > The application has two parts
    > 1. returns all text data in the <test> input as is to STDOUT


    Where is the code that does that?

    > 2. returns function call with return values also to STDOUT


    Where is the code that does that?
    >
    > Now what happens is that category 1 collects in out.txt
    > while category 2 collects in the $variable
    >
    > my question is why does STDOUT get split into 2 places and how can I
    > avoid it - I want all to goto the variable


    Without seeing some of the code, it is hard to say. Maybe some of the
    printing happens before the redirect takes place. Maybe some of the
    printing happens in spawned processes which aren't affected your hacking of
    the perl symbol table.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Apr 25, 2007
    #2
    1. Advertising

  3. Klaus Guest

    On Apr 25, 10:40 pm, wrote:
    > Hi have a perl application in on suse64 bit OS, which internally
    > redirects STDOUT to a $variable
    > using
    > This redirects STDOUT to a variable
    >
    > open OUT ,'>',\$variable
    > *STDOUT = *OUT
    >
    > Now when run the tool
    > e.g ./app <test>.txt > out.txt
    >
    > The application has two parts
    > 1. returns all text data in the <test> input as is to STDOUT
    > 2. returns function call with return values also to STDOUT
    >
    > Now what happens is that category 1 collects in out.txt
    > while category 2 collects in the $variable
    >
    > my question is why does STDOUT get split into 2 places and how can I
    > avoid it - I want all to goto the variable


    I am guessing that your function call has external commands (for
    example system(), `...`, qx(), etc...). If that is the case, then the
    bad news is that the STDOUT of those external commands will not be
    captured by *STDOUT = *OUT

    I have never tried it myself, but PerlFaq8: "How can I capture STDERR
    from an external command?" might give some ideas.

    --
    Klaus
     
    Klaus, Apr 26, 2007
    #3
  4. Guest

    On Apr 26, 1:29 am, Klaus <> wrote:
    > On Apr 25, 10:40 pm, wrote:
    >
    >
    >
    > > Hi have a perl application in on suse64 bit OS, which internally
    > > redirects STDOUT to a $variable
    > > using
    > > This redirects STDOUT to a variable

    >
    > > open OUT ,'>',\$variable
    > > *STDOUT = *OUT

    >
    > > Now when run the tool
    > > e.g ./app <test>.txt > out.txt

    >
    > > The application has two parts
    > > 1. returns all text data in the <test> input as is to STDOUT
    > > 2. returns function call with return values also to STDOUT

    >
    > > Now what happens is that category 1 collects in out.txt
    > > while category 2 collects in the $variable

    >
    > > my question is why does STDOUT get split into 2 places and how can I
    > > avoid it - I want all to goto the variable

    >
    > I am guessing that your function call has external commands (for
    > example system(), `...`, qx(), etc...). If that is the case, then the
    > bad news is that the STDOUT of those external commands will not be
    > captured by *STDOUT = *OUT
    >
    > I have never tried it myself, but PerlFaq8: "How can I capture STDERR
    > from an external command?" might give some ideas.
    >
    > --
    > Klaus


    Thanks for the tip - yes my code does use external perl modules to
    return values - different modules return different things and somehow
    these are not in order when I try to collect them, the problem is this
    does not happen is SUSE32 - is their an OS dependency
     
    , Apr 26, 2007
    #4
  5. Klaus Guest

    On Apr 26, 8:47 pm, wrote:
    > On Apr 26, 1:29 am, Klaus <> wrote:
    > > I am guessing that your function call has external commands (for
    > > example system(), `...`, qx(), etc...).


    > Thanks for the tip - yes my code does use external perl modules to
    > return values


    Please copy and paste a section from your perl program where you
    actually call the external perl modules (if possible no more than 10
    lines).

    --
    Klaus
     
    Klaus, Apr 27, 2007
    #5
  6. <> wrote:
    > On Apr 26, 1:29 am, Klaus <> wrote:



    >> I am guessing that your function call has external commands (for
    >> example system(), `...`, qx(), etc...).



    >> --
    >> Klaus



    It is bad netiquette to quote signatures.


    > Thanks for the tip - yes my code does use external perl modules to
    > return values



    A "command" is not the same thing as a "module".

    He did not ask if you use external modules, he asked if you
    used external (command line) commands.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Apr 27, 2007
    #6
    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. Acaccia

    stdout redirection

    Acaccia, Jan 16, 2004, in forum: C++
    Replies:
    3
    Views:
    11,994
    Acaccia
    Jan 16, 2004
  2. Terry Gray

    os.system stdout redirection...

    Terry Gray, Aug 17, 2003, in forum: Python
    Replies:
    8
    Views:
    3,201
    baiste
    Oct 11, 2003
  3. Joel Wagner

    Redirection of stdout fails on Windows

    Joel Wagner, Oct 9, 2003, in forum: Python
    Replies:
    1
    Views:
    785
    Daniel Dittmar
    Oct 10, 2003
  4. Jeff Epler

    Re: sys.stdout redirection

    Jeff Epler, Jul 19, 2004, in forum: Python
    Replies:
    0
    Views:
    444
    Jeff Epler
    Jul 19, 2004
  5. Holger Joukl

    Re: sys.stdout redirection

    Holger Joukl, Jul 19, 2004, in forum: Python
    Replies:
    0
    Views:
    466
    Holger Joukl
    Jul 19, 2004
Loading...

Share This Page