pattren maching and mail sending please help !
- From: juanbabi@xxxxxxxxx (Juanbabi@xxxxxxxxx)
- Date: 22 Oct 2007 19:57:13 -0700
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 <syslog@xxxxxxxxxxx>',
'To' => 'gabriela <gabriela@xxxxxxxxxxx>',
'Subject' => 'PiX Detected Attack ' );
print $mailer <<$message;
close($mailer) or die "can't close mailer: $!";
when I execute the script I got this:
[root@juanlinux 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
.
- Follow-Ups:
- Re: pattren maching and mail sending please help !
- From: Gunnar Hjalmarsson
- Re: pattren maching and mail sending please help !
- Prev by Date: How do I properly use global variables?
- Next by Date: Re: Getting error message while installing Crypt-DSA module
- Previous by thread: How do I properly use global variables?
- Next by thread: Re: pattren maching and mail sending please help !
- Index(es):
Relevant Pages
|
|