Short, correct and useless answer: yes.
Longer answer: any message written by the program is written to a certain file descriptor. Typically, error messages go to standard error, but if I got a nickle for every error message going to standard output, or half a cent for any non-error message going to standard error, I could buy Microsoft, IBM and Oracle, and still have cash to spare.
So, you would have to find out where the programs error messages are going, and redirect that channel. For instance, in Posix like shells, messages on standard error (file descriptor 2) can be redirected to a file like this:
program 2> errors_go_here
| [reply] [d/l] |
You could, but it all depends on what you do with standard output; if you want to capture only the errors, and are not interested in standard output, this should work (in bash-like shells:
ERRORTEXT=`perl -e 'die "Oops"' 2>&1 1>/dev/null`
ERRORCODE=$?
You can complicate things if you want both standard output and error captures, like:
ERRORTEXT=`perl -e 'print "Hello\n";die "Oops"' 3>&1 1>&2 2>&3`
ERRORCODE=$?
Above sniplet prints Hello to standard error(!) and captures the result of 'die' in $ERRORTEXT. But then: why not extend your Perl program to handle what you want in the first place?
Paul | [reply] [d/l] [select] |