My name is juan. im totally new with perl...
Im trying to write a script which will read from /var/log/messages and send a mail each time a line with the word IDS is found. I want that the whole line will be sended by mail:
this is what I wrote:
when I execute the script I get this:#!/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@hpda.com.ar>', 'To' => 'gabriela pinado <gabriela.pinado@hpda.com +.ar>', 'Subject' => 'PiX Detected Attack ' ); print $mailer <<@message; close($mailer) or die "can't close mailer: $!";
I get so much errors and I dont know how to hendle them... please give me a hend !!![root@juanlinux perl]# perl ./logcheck Array found where operator expected at ./logcheck line 14, at end of l +ine (Do you need to predeclare g?) 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. Array found where operator expected at ./logcheck line 22, at end of l +ine (Might be a runaway multi-line << string starting on line 20) (Missing operator before ?) 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 l +ine 16. Global symbol "$mailer" requires explicit package name at ./logcheck l +ine 17. Global symbol "$mailer" requires explicit package name at ./logcheck l +ine 20. Global symbol "$mailer" requires explicit package name at ./logcheck l +ine 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.
thanks a lot for your time and help!
Juan
In reply to pattern matching and sending mail! by juanb007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |