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

start external program getting return code, stdout and stderr

by some_coder (Initiate)
on Sep 04, 2012 at 14:33 UTC ( #991632=perlquestion: print w/ replies, xml ) Need Help??
some_coder has asked for the wisdom of the Perl Monks concerning the following question:

Hello, i know that i can start external progams using system or some kind of open(PROCESS,'<programname> |'). As far as i know both variants return either the return code of the called program (e.g. 0 for success, 1 for error) or the return values sent to stdout. I need an blocking call like system() and all three output values.

Let me explain what i want to accomplish. I want to call "apachefop" to generate some pdfs. apachefop prints massive warnings on stdout/stderr. Exceptions where displayed on stdout/stderr either. i want to log all the displayed errors and warnings only if the program did exit with an error. if it exits successfully i want to ignore the warnings.

i hope you can help me or point me to the right direction. Ah before i forget it, i am using Perl 5.8.8 in an Apache/mod_perl environment.

Comment on start external program getting return code, stdout and stderr
Select or Download Code
Re: start external program getting return code, stdout and stderr
by Athanasius (Prior) on Sep 04, 2012 at 14:49 UTC

    Hello some_coder, and welcome to the Monastery!

    The CPAN module Capture::Tiny will capture the output of STDOUT and STDERR (separately), as well as the return value of the called code. You can then use the return value to decide what (if anything) you want to do with the captured output.

    See the recent thread Problem logging STDOUT in perl.

    Hope that helps,

    Athanasius <°(((><contra mundum

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://991632]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-04-18 00:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (460 votes), past polls