problem runing code | strange Error

2007-10-23 Thread Juan B

-Hi,

Im trying to run this code: (im getting this error
message):

Can't use string (From) as a HASH ref while strict
refs in use at
/usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm line
320.

The code:

use strict;
use warnings;
use Mail::Mailer;

my @lines = ();
open (INFO, /var/log/messages) or die $!;
while (my $line = INFO) {
   if ($line =~ /IDS/) {
  push @lines,$line;
   }
}
close INFO;
if (@lines) {
   my $mailer = Mail::Mailer-new(smtp,
10.83.27.71);
   $mailer-open( 'From' = 'Syslog
[EMAIL PROTECTED]',
  'To' = 'gabriela pinado
[EMAIL PROTECTED]',
  'Subject' = 'PiX Detected Attack '
);
   print $mailer @lines;
   $mailer-close or die can't close mailer: $!;
}

Any ideas where is the problem?

thanks a lot !

Juan


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: problem runing code | strange Error

2007-10-23 Thread Juan B
Hi,

I did it and know I get another error:

syntax error at logcheck line 25, near 'PiX Detected
Attack } ' )
Missing right curly or square bracket at logcheck line
28, at end of line
Execution of logcheck aborted due to compilation
errors.

This is the code:

use strict;
use warnings;
use Mail::Mailer;

my @lines = ();
open (INFO, /var/log/messages) or die $!;
while (my $line = INFO) {
   if ($line =~ /IDS/) {
  push @lines,$line;
   }
}
close INFO;
if (@lines) {
   my $mailer = Mail::Mailer-new(smtp,
10.83.27.71);
  $mailer-open( {'From' = 'Syslog
[EMAIL PROTECTED]',
  'To' = 'gabriela pinado
[EMAIL PROTECTED]',
  'Subject' = 'PiX Detected Attack }
' );
   print $mailer @lines;
   $mailer-close or die can't close mailer: $!;


thanks a lot !

Juan


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: problem runing code | strange Error

2007-10-23 Thread Juan B
Ok I did it and know I get another error :-(
here goes the error:
 Died at /usr/lib/perl5/site_perl/5.8.8/Mail/Mailer.pm
line 284.



this is the code:
use strict;
use warnings;
use Mail::Mailer;

my @lines = ();
open (INFO, /var/log/messages) or die $!;
while (my $line = INFO) {
   if ($line =~ /IDS/) {
  push @lines,$line;
   }
}
close INFO;
if (@lines) {
   my $mailer = Mail::Mailer-new(smtp,
10.83.27.71);
  $mailer-open({
'From' = 'Syslog [EMAIL PROTECTED]',
'To' = 'gabriela pinado
[EMAIL PROTECTED]',
'Subject' = 'PiX Detected Attack'
});
   print $mailer @lines;
   $mailer-close or die can't close mailer: $!;
}
~

please assist!

thanks very much !

Juan


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




help with reading file script | Help !!

2007-10-19 Thread Juan B
Hi all !!

im really new to perl so please bare with me and
help..

I need a script to read /var/log messages and each
time it sees a line with the word IDS it will send
the whole line via mail to the administrator of the
IDS, here is an example of such a line:
Oct 19 15:40:30 172.31.0.254 %PIX-4-400011: IDS:2001
ICMP unreachable from 200.69.22.146 to 200.61.54.55 on
interface outside

I wrote this script:

#!/usr/local/bin/perl

$file = '/var/log/messages';  # Name the file
open(INFO, /var/log/messages);   # Open the file

while
$message = INFO / IDS/g {# Read it
into an array
 $ message = $


 sub sendEmail # simple Email function

 my $sendmail = '/usr/lib/sendmail';
 open(MAIL, |$sendmail -oi -t);
 print MAIL From: [EMAIL PROTECTED];
 print MAIL To: [EMAIL PROTECTED];
 print MAIL Subject: Pix IPS Attck Detection\n\n;
 print MAIL $message\n;
 close(MAIL);
 }

It doesnt work and I dont know why... can someone
help?

another question, how to execute this script so it
will be in memory oc the server all the time? should I
run it throw rc.local? 

thanks a lot for helping me !!

thanks !

Juan


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




how to send mail within a script ?

2005-10-22 Thread Juan B
HI,

I am trying to write a script which will send the
result of a var to mail web mail.this is what I wrote
:

#!/usr/bin/perl
#use strict;
use warnings;
my $file_listing = `/usr/bin/nmap -p 80 192.168.1.1`;

How can it be done? do I need to configure sendmail on
my linux box. please try to give a simple solutio
cause im new in perl.

thanks,

Juan



__ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




helping writing a script

2005-10-16 Thread Juan B
Hi guys !

I have four html pages. within eack one I have a
firewalls logs.I need to write a script that will
search all the ip address after the work from: and
wrote tham in a file and if the ip is written already
in the report file so dont write in again.

please help me on this or give me some clues cause im
realy new in perl and I need to learn how to use it
better !!

thanks very much !

juan 




__ 
Yahoo! Mail - PC Magazine Editors' Choice 2005 
http://mail.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response