Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Reset STDERR to console

by sundialsvc4 (Abbot)
on Apr 01, 2011 at 17:05 UTC ( [id://896954]=note: print w/replies, xml ) Need Help??


in reply to Reset STDERR to console

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://896954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found