Hi,
My name is juan. Im very new to Perl so please give me a hand here, Im
working on this script lot of time and without sucess.
I need a script which will read and send mail each time a message
with the word IDS is generated under /var/log/messages.
this is the script, which I know have lots of errors:
#!/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 = <INFO> / IDS/g # Read it into an array
$message = $&
$mailer = Mail::Mailer->new("smtp", "10.83.27.71");
$mailer->open( 'From' => 'Syslog <[EMAIL PROTECTED]>',
'To' => 'gabriela <[EMAIL PROTECTED]>',
'Subject' => 'PiX Detected Attack ' );
print $mailer <<$message;
close($mailer) or die "can't close mailer: $!";
when I execute the script I got this:
[EMAIL PROTECTED] perl]# perl ./logcheck
Scalar found where operator expected at ./logcheck line 16, near "$&
$mailer"
(Missing semicolon on previous line?)
Use of bare << to mean <<"" is deprecated at ./logcheck line 20.
Scalar found where operator expected at ./logcheck line 22, near
"$message"
(Might be a runaway multi-line << string starting on line 20)
(Missing operator before $message?)
syntax error at ./logcheck line 13, near "{"
Global symbol "$message" requires explicit package name at ./logcheck
line 13.
Global symbol "$message" requires explicit package name at ./logcheck
line 14.
Global symbol "$mailer" requires explicit package name at ./logcheck
line 16.
Global symbol "$mailer" requires explicit package name at ./logcheck
line 17.
Global symbol "$mailer" requires explicit package name at ./logcheck
line 20.
Global symbol "$mailer" requires explicit package name at ./logcheck
line 20.
syntax error at ./logcheck line 22, near "$message"
Global symbol "$message" requires explicit package name at ./logcheck
line 22.
Execution of ./logcheck aborted due to compilation errors.
can someone please help me a bit? I dont know how to fix all of
this !!
thanks a lot !!
Juan
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/