perl ${SCRIPT} /tws/dv/event.log "101 " #!/usr/bin/perl -s if (@ ARGV[0] =~ /\bhelp\b/) { print "Usage: KeywordSearch.pl \/filename> \n"; exit 1; } chomp($file = @ ARGV[0]); chomp($pattern = @ ARGV[1]); if (length($file)==0||length($pattern)==0){ print "Message: Bad argument! Please see help\n"; print "Statistic: 0\n"; exit 1; } else { if (!-e $file){ print "Message: \"$file\" (File NOT FOUND!)\n"; print "Statistic: 0\n"; exit 1; } } open (F, '<', $file) || die $!; my @lines = ; foreach my $line (@lines) { if ($line =~ /\Q$pattern\E/) { print "Message: \"$pattern\" (Pattern FOUND)\n"; print "Statistic: 1\n"; exit 0; } } print "Message: \"$pattern\" (Pattern NOT FOUND)\n"; print "Statistic: 0\n"; exit 0