M
Mike Paolucci
I'm getting unexplained errors when I read from a log file. I'm using a
"Safe Pipe Open", and my reference for this is:
http://www.litespeed.net/perldocs/lib/Pod/perlipc.html#Using_open_for_IPC
Here's the code:
my $logFile = 'full_path_to_logfile'; (not specified for confidentially)
my $ipAddress = '12.34.56.78'; (not specified for confidentially)
my $fh;
open( $fh, "grep $ipAddress $logFile | tail 2>&1 |" ) or
die "Cannot open logfile!!\n";
# get the last lines
my $logData = '';
while ( <$fh> )
{
$logData .= $_;
}
close( $fh ) or die "Cannot close logfile!\n";
# display these lines
print $logData;
The code works perfectly and displays no errors. The probem is that
when I look in the system error file I see lines and lines of:
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
Why are these errors there?
What do they mean?
How do I prevent them?
"Safe Pipe Open", and my reference for this is:
http://www.litespeed.net/perldocs/lib/Pod/perlipc.html#Using_open_for_IPC
Here's the code:
my $logFile = 'full_path_to_logfile'; (not specified for confidentially)
my $ipAddress = '12.34.56.78'; (not specified for confidentially)
my $fh;
open( $fh, "grep $ipAddress $logFile | tail 2>&1 |" ) or
die "Cannot open logfile!!\n";
# get the last lines
my $logData = '';
while ( <$fh> )
{
$logData .= $_;
}
close( $fh ) or die "Cannot close logfile!\n";
# display these lines
print $logData;
The code works perfectly and displays no errors. The probem is that
when I look in the system error file I see lines and lines of:
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
grep: writing output: Broken pipe
Why are these errors there?
What do they mean?
How do I prevent them?