Imported Upstream version 2.3
[ossec-hids.git] / src / os_regex / examples / validate.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 if(@ARGV < 2)
7 {
8     die "$0 file error_msg\n";
9 }
10
11 my ($prog, $file,$msg) = (@ARGV);
12
13 open(FILE,$file) || die "Error opening file: $file\n";
14
15 if(! -f $prog)
16 {
17         die "File $prog not present\n";
18 }
19
20 while(<FILE>)
21 {
22     my $line = $_;
23     print "running: $prog $line\n";
24     my $result =  `$prog $line`;
25     if($result =~ /$msg/)
26     {
27         print $result;
28         print "\t ** $line **\n";
29         <STDIN>;
30     }
31     else
32     {
33         print $result;
34     }
35 }
36
37 # EOF