in reply to Re^3: Print STDOUT and STDERR to file and to console
in thread Print STDOUT and STDERR to file and to console
The problem with the example above is that I can’t catch an error messages (STDERR) and print them to log file and the console. Any Idea how to handle the STDERR as well? Thanks.open(LOG, "> $LOG_FILE") || die "Can't redirect stdout"; #open(STDERR, ">&LOG") || die "Can't dup stdout"; open (CMD, " ls |"); while (<CMD>) { lprint ($_) } close(CMD); sub lprint () { my ($line) = @_; print LOG $line; # print STDERR $line; # print STDERR $_; print $line; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Print STDOUT and STDERR to file and to console
by Anonymous Monk on Aug 02, 2009 at 15:34 UTC | |
|
Re^5: Print STDOUT and STDERR to file and to console
by Anonymous Monk on Aug 02, 2009 at 07:28 UTC | |
by Noame (Beadle) on Aug 02, 2009 at 09:14 UTC | |
by Anonymous Monk on Aug 02, 2009 at 09:37 UTC | |
by Noame (Beadle) on Aug 02, 2009 at 11:52 UTC | |
by Your Mother (Archbishop) on Aug 02, 2009 at 17:49 UTC | |
by Anonymous Monk on Aug 03, 2009 at 04:04 UTC |