From: John D. <du...@gm...> - 2007-11-21 23:33:50
|
Kevin, thank you for comprehensive reply. > Well, the safest and most direct way would be to replace/augment all the > prints to STDERR (like "warn" and "die") inside your script with > log4perl logger calls. I would prefer this solution, but how can I the redirect whole output (or STDERR atleast) of the external command to die? I am almost perl beginner, sorry, if this question is too easy. > > Or you could pipe the output of your script to another script that reads > STDIN and implements logging like this: > > command 2>&1 | perl -e 'use Log::Log4perl qw/:easy/; \ > Log::Log4perl::easy_init($INFO); \ > while (<STDIN>){INFO $_}' Can I do this in perl script directly? use Log::Log4perl qw/:easy/; Log::Log4perl::easy_init($INFO); $pid = open(STDIN, "ls nonsense 2>/dev/null |"); while (<STDIN>){INFO $_}; Is there any way how to redirect STDOUT to INFO and STDERR to ERROR? If both is not possible, STDERROR to ERROR is more important. Thanks. -John |