M
Mike Hunter
Hi,
I have some cron jobs that can sometimes send out too much noise to stderr,
which in turn causes sendmail to do bad things I'm trying to limit the
amount of stderr I see from those scripts without changing the scripts
themselves. I am looking to write a perl wrapper that does something like this:
my $program = shift @ARGV;
my $args = join " ", @ARGV;
open PGMSTDOUT, "$program $args|" or die "blah!";
......somehow get the program's stdout into PGMSTDOUT
while (<PGMSTDOUT>)
{
print $_;
}
my $n = 0;
my $error_line = <PGMSTDERR>;
while (<PGMSTDERR> && ($n < 1000))
{
$error_line = <PGMSTDERR>;
print STDERR $error_line;
$n++;
}
The only similar advice I've seen on the web was here:
http://perlmonks.thepen.com/730.html
But I don't want to follow that approach because I don't want to create a file
on disk with all the STDERR stuff, I want to discard it.
Any help? How do I *pipe* stderr to something without duping it to stdout?
Thanks,
Mike
I have some cron jobs that can sometimes send out too much noise to stderr,
which in turn causes sendmail to do bad things I'm trying to limit the
amount of stderr I see from those scripts without changing the scripts
themselves. I am looking to write a perl wrapper that does something like this:
my $program = shift @ARGV;
my $args = join " ", @ARGV;
open PGMSTDOUT, "$program $args|" or die "blah!";
......somehow get the program's stdout into PGMSTDOUT
while (<PGMSTDOUT>)
{
print $_;
}
my $n = 0;
my $error_line = <PGMSTDERR>;
while (<PGMSTDERR> && ($n < 1000))
{
$error_line = <PGMSTDERR>;
print STDERR $error_line;
$n++;
}
The only similar advice I've seen on the web was here:
http://perlmonks.thepen.com/730.html
But I don't want to follow that approach because I don't want to create a file
on disk with all the STDERR stuff, I want to discard it.
Any help? How do I *pipe* stderr to something without duping it to stdout?
Thanks,
Mike