Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Error trapping while capturing stdout

by ccarden (Monk)
on Sep 14, 2004 at 15:35 UTC ( [id://390876]=note: print w/replies, xml ) Need Help??


in reply to Re: Error trapping while capturing stdout
in thread Error trapping while capturing stdout

Thanks for confirming my understanding of 2>&1|.

Now you got me thinking, with your second point. The called script does, indeed exit with a code. How would perl -w affect that? If perl gives warnings, it doesn't change the script's exit code. So I could still get an exit code of 0, but with warnings from the interpreter.

Another unwanted behavior that wasn't trapped was perl exiting with a "bad interpreter" message. I tracked it down to hidden carriage returns (thanks to vi's [dos] message), but the calling script should have caught that. I'll test your suggestion for trapping.

Thanks.

Replies are listed 'Best First'.
Re^3: Error trapping while capturing stdout
by Random_Walk (Prior) on Sep 14, 2004 at 16:15 UTC

    You would still get the warnings if you redeirected STDERR to STDOUT but if you trust the called script to exit non-zero when it fails then you no longer need to examine STDERR. You can throw it away with 2>&/dev/null and just test the exit value from the script.

    Fixing the warnings may also help ;-)

    The bad interpreter error would also return a non-zero value to the calling script and get caught in the $? test.

    Cheers,
    R.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found