Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: How to capture child process output and divert to log4perl

by ww (Bishop)
on Sep 14, 2012 at 18:41 UTC ( #993775=note: print w/ replies, xml ) Need Help??


in reply to How to capture child process output and divert to log4perl

Does any of this (truncated) look helpful? relevant?

C:\>perldoc -q stderr Found in C:\Perl\lib\pods\perlfaq8.pod How can I capture STDERR from an external command? There are three basic ways of running external commands: system $cmd; # using system() $output = `$cmd`; # using backticks (``) open (PIPE, "cmd |"); # using open() With "system()", both STDOUT and STDERR will go the same place as +the script's STDOUT and STDERR, unless the "system()" command redirect +s them. Backticks and "open()" read only the STDOUT of your command. You can also use the "open3()" function from "IPC::Open3". Benjami +n Goldberg provides some sample code: To capture a program's STDOUT, but discard its STDERR: use IPC::Open3; use File::Spec; use Symbol qw(gensym); open(NULL, ">", File::Spec->devnull); my $pid = open3(gensym, \*PH, ">&NULL", "cmd"); while( <PH> ) { } waitpid($pid, 0); To capture a program's STDERR, but discard its STDOUT: use IPC::Open3; use File::Spec; use Symbol qw(gensym); open(NULL, ">", File::Spec->devnull); my $pid = open3(gensym, ">&NULL", \*PH, "cmd"); while( <PH> ) { }


Comment on Re: How to capture child process output and divert to log4perl
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2014-10-22 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (114 votes), past polls