Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am not sure that you can read from STDERR while it is being written to, and of course if (say) it was being directed to a pipe or to /dev/null you couldn’t read it anyhow.

So, what if we try this ...   In a shell script or somesuch, invoke your Perl program, taking care to put STDERR specifically to somewhere you can capture it.   Capture STDOUT, separately, in the same way.   When the Perl program ends, the shell script now cats (or types) those two streams into its own (the shell script’s...) STDOUT and/or STDERR as appropriate.   The shell script is now simply a “wrapper,” and the job is done.

It could be very simple ... like this sketch of an idea:

perl ... your_program_name ... 1>/tmp/stdout 2>/tmp/stderr cat /tmp/stdout cat /tmp/stderr rm /tmp/stdout /tmp/stderr

No, “the job wasn’t done in the way” that you might now be considering, but ... “the job is done.”   It’s clean, and obvious, and very easily changed.   Win32 and Unix/Linux implementations of the same idea are equally trivial.


In reply to Re: Reset STDERR to console by sundialsvc4
in thread Reset STDERR to console by saintex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-16 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found