While I was waiting I tried a few things and am up to here:
Which is SOOO close. The stuff all comes out in order, but I think the print function is getting some STDERR messages in chinks. However I don't mind TOO much because all I REALLY want to do is prepend and append html tags. So is there a reason why I couldn't turn the run statment into#!/opt/local/bin/perl -w use IPC::Run qw( run new_chunker ); use File::Basename; #need two arguments: script to run and mailing list (comma-separated m +1 ids) $#ARGV == 1 || die "Error: Need exactly two arguments!\n"; ($base, $dir, $ext)=fileparse($ARGV[0],'\..*'); #Do some machinations to create a unique overall log file @now=localtime; #month returned by localtime() are zero-indexed. #got to pad the zeroes for the time/date elements $mo=sprintf("%02d",$now[4]+1); $d=sprintf("%02d",$now[3]); $y=$now[5]+1900; $h=sprintf("%02d",$now[2]); $mi=sprintf("%02d",$now[1]); $workdir="/fma/prod1/isa/logs"; $logfile="$workdir/$base-$y$mo$d.$h$mi.m1jwc03.log"; open(LOG,">$logfile") || die "Error: Could not open $logfile: $!\n"; my $oldfh=select(LOG) || die "Error: Could not select LOG: $!\n"; print "*-*-begin_run-*-*\n"; ($distlist = $ARGV[1]) =~ s/,/ /g; print "*-*-on_error $distlist-*-*\n"; chdir("$dir"); @cmd=$ARGV[0]; $SIG{CHLD} = sub { print "NOTE: in sig{CHLD}\n"; # if (waitpid($pid, 0) > 0){sleep(1);}; }; { run (\@cmd, '>pty>', sub{ print "STDOUT: $_[0]";}, '2>', sub { prin +t "STDERR: $_[0]";}) or die("Error executing child. Child returned $& +\n"); } print "*-*-end_run-*-*\n"; close(LOG);
?run (\@cmd, '>pty>', sub{ print "$_[0]";}, '2>', sub { print "<b><big> +STDERR: $_[0]</b></big>";}) or die("Error executing child. Child retu +rned $&\n");
________________________________________________________________________________
Without me, it's just aweso
In reply to Re^4: Prepending a string to STDERR output, and logging STDOUT & STDERR synchronously to a file
by OfficeLinebacker
in thread Prepending a string to STDERR output, and logging STDOUT & STDERR synchronously to a file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |