#!/usr/local/bin/perl # Program to check /var/log/messeges for alerts contining the word IDS and send mails # in case the word is found- including the line use strict; use warnings; use Mail::Mailer; open (INFO, "/var/log/messages"); # Open the file while { @message = / IDS/g # Read it into an array @message = $& $mailer = Mail::Mailer->new("smtp", "10.83.27.71"); $mailer->open( 'From' => 'Syslog ', 'To' => 'gabriela pinado ', 'Subject' => 'PiX Detected Attack ' ); print $mailer <<@message; close($mailer) or die "can't close mailer: $!"; #### #!/usr/local/bin/perl use strict; use warnings; use Mail::Mailer; my $mailer = Mail::Mailer->new("smtp", "10.83.27.71"); open (INFO, "/var/log/messages"); while (my $message = ) { next unless $message =~ / IDS/; $mailer->open( 'From' => 'Syslog ', 'To' => 'gabriela pinado ', 'Subject' => 'PiX Detected Attack ' ); print $mailer $message; $mailer->close() or die "can't close mailer: $!"; } close INFO;