Need some help with my if statement. It works for with pulling all of the Priority: 2 out of the file, but when I try to exclude ICMP it doesn't work. I know != is for numbers but I get errors with ne as well. Here is my code, any suggestions are appreciates.
#!/usr/bin/perl -w
use FileHandle;
$| = 1;
# open file and define a handle for it
open(FILE,"/var/log/snort/alert"
|| die "Unable to open Coolips!\n";
# suck the file into an array
@file = <FILE>;
# close file when done
close(FILE);
#open the file for wrniting, append to whatever data may be there
open (FILE2, ">>/var/snort/relevantp2"
|| die "Unable to open file!\n";
autoflush FILE2 1;
$|=1;
# use a loop to keep reading the file
# until it reaches the end
foreach $line (@file)
{
if (($line =~ /Priority: 2/)&& ($line != /ICMP/)){
print FILE2 $line ;
}
}
close(FILE2);
When faced with a decision, always ask, 'Which would be the most fun?'
#!/usr/bin/perl -w
use FileHandle;
$| = 1;
# open file and define a handle for it
open(FILE,"/var/log/snort/alert"
# suck the file into an array
@file = <FILE>;
# close file when done
close(FILE);
#open the file for wrniting, append to whatever data may be there
open (FILE2, ">>/var/snort/relevantp2"
autoflush FILE2 1;
$|=1;
# use a loop to keep reading the file
# until it reaches the end
foreach $line (@file)
{
if (($line =~ /Priority: 2/)&& ($line != /ICMP/)){
print FILE2 $line ;
}
}
close(FILE2);
When faced with a decision, always ask, 'Which would be the most fun?'