Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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> ) { }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993775]
help
Chatterbox?
[stevieb]: I am thankful that I fell into Perl years ago in the manner I did. I don't believe there is another language that people care about so much, that they're willing to give everything. Langs come and go, but in Perl, it seems, things remain consistent.

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-02-25 01:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (364 votes). Check out past polls.