The script write to stdout, but won't write to a file. Does anyone know what's going on?? I have to have this done by Friday, so I would really appreciate ANY help. Thanks so much.
Jewel
#!/usr/bin/perl -w
BEGIN { unshift @INC,"./blib/lib/";}
use File::Tail 0.98;
$name="/var/log/snort/alert" unless $name=shift @ARGV;
$debug=shift @ARGV || 0;
#open the file for writing, append to whatever data may be there
open (file2, ">> /var/log/snort/alert2" || die "opening alert2: $!";
print "Looking at $name \n";
#
# This is the old, pure object, interface
#
$file=File::Tail->new(name=>$name,debug=>$debug,interval=>1,maxinterval=>5,
adjustafter=>20,errmode=>"return" or
die "Could not open $name: $!";
while ($line=$file->read) {
if ($Found) {
print $line;
print file2 $line;
$Found = 0;
next;
}
if($line =~ /Priority: 1/){
print $line;
print file2 $line;
$Found = 1;
}
}
Jewel
#!/usr/bin/perl -w
BEGIN { unshift @INC,"./blib/lib/";}
use File::Tail 0.98;
$name="/var/log/snort/alert" unless $name=shift @ARGV;
$debug=shift @ARGV || 0;
#open the file for writing, append to whatever data may be there
open (file2, ">> /var/log/snort/alert2" || die "opening alert2: $!";
print "Looking at $name \n";
#
# This is the old, pure object, interface
#
$file=File::Tail->new(name=>$name,debug=>$debug,interval=>1,maxinterval=>5,
adjustafter=>20,errmode=>"return" or
die "Could not open $name: $!";
while ($line=$file->read) {
if ($Found) {
print $line;
print file2 $line;
$Found = 0;
next;
}
if($line =~ /Priority: 1/){
print $line;
print file2 $line;
$Found = 1;
}
}