in reply to Re^7: Print STDOUT and STDERR to file and to console
in thread Print STDOUT and STDERR to file and to console
The problem with the code above is that I didn’t successes to control the STDERR output Please advice.open(LOG, "> $LOG_FILE") || die "Can't redirect stdout"; open(STDERR, "> $LOG_FILE") || die "Can't dup stdout"; #open(STDERR, ">&STDOUT") || 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^9: Print STDOUT and STDERR to file and to console
by Your Mother (Archbishop) on Aug 02, 2009 at 17:49 UTC | |
|
Re^9: Print STDOUT and STDERR to file and to console
by Anonymous Monk on Aug 03, 2009 at 04:04 UTC |