OK, the change could be make in the following area: open MYMESSGELOGFILE, "< /var/log/messages"; open MYSECURELOGFILE, "< /var/log/secure";
my @messageLog = <MYMESSGELOGFILE>; my @secureLog = <MYSECURELOGFILE>; close MYMESSGELOGFILE; close MYSECURELOGFILE; I would write it like this: my @secureLog; my @messageLog; my $thisline; my $date = $currentdateiamlookingtoputinmyemailwhenifinishthisscript; open MYMESSGELOGFILE, "< /var/log/messages"; while $thisline=(<MYMESSGELOGFILE>) { if ($thisline!~/$date/) {next;} unshift ($thisline,@messageLog); } close MYMESSGELOGFILE; open MYSECURELOGFILE, "< /var/log/secure"; while $thisline=(<MYSECURELOGFILE>) { if ($thisline!~/$date/) {next;} unshift ($thisline,@secureLog); } close MYSECURELOGFILE; or even cut it down a bit with standard tools: while <MYSECURELOGFILE> { if ($_!~/$date/) {next;} unshift @secureLog; } or something like that....... I am sure that there are easier ways to do it, but do your own thing! The thing is, you need to sift your flour before you bake the cake! --------------------------------------------------------------------------- James Hughes DREGIS Dresdner Global IT-Services Gesellschaft mbH Bankbetrieb Server u. Geschäftsstellenservices (SH GM) Telephone +49 (0) 69 / 2 63 - 82653 Fax +49 (0) 69 / 2 63 - 10 347 Wilhelm-Leuschner-Straße 4-6, 4. OG 60627 Frankfurt / Main, Germany E-Mail [EMAIL PROTECTED] -----Ursprüngliche Nachricht----- Von: Matt Wetherill [mailto:[EMAIL PROTECTED]] Gesendet: Freitag, 19. Juli 2002 10:21 An: [EMAIL PROTECTED] Betreff: Script advice Hi List, As a (very) newbie, I'd just like to seek some opinion on the following script - it mails a copy of some log files to me as a cron job from a linux box: #!/usr/bin/perl -w use Net::SMTP; open MYMESSGELOGFILE, "< /var/log/messages"; open MYSECURELOGFILE, "< /var/log/secure"; my @messageLog = <MYMESSGELOGFILE>; my @secureLog = <MYSECURELOGFILE>; close MYMESSGELOGFILE; close MYSECURELOGFILE; $smtp = Net::SMTP->new('post.salford.ac.uk'); # connect to SMTP server $smtp->mail( '[EMAIL PROTECTED]' ); # sender's address $smtp->to('[EMAIL PROTECTED]'); # recipient's address $smtp->data(); # Start the mail # Send the header. $smtp->datasend("To: m.wetherill\n"); $smtp->datasend("From: banana\n"); $smtp->datasend("\n"); # Send the body. $smtp->datasend("Message Log file: /var/log/message starts\n\n:"); $smtp->datasend("@messageLog\n"); $smtp->datasend("Message Log file: /var/log/message ends\n\n\n\n:"); $smtp->datasend("Secure Log file: /var/log/secure starts\n\n:"); $smtp->datasend("@secureLog\n"); $smtp->datasend("Secure Log file: /var/log/secure ends\n:"); $smtp->dataend(); # Finish sending mail $smtp->quit; # Close SMTP connection However, this script just mails the whole file - what I'd really like to do is just mail the current days entries, but this is defeating me! many thanks advance Matt - ****************************** Matt Wetherill University of Salford [EMAIL PROTECTED] mobile: +44 7812 016059 office: +44 161 295 5853 ****************************** "Never try to teach a pig to sing...it wastes your time and it annoys the pig." - Anon. - ****************************** Matt Wetherill University of Salford [EMAIL PROTECTED] mobile: +44 7812 016059 office: +44 161 295 5853 ****************************** --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.377 / Virus Database: 211 - Release Date: 15/07/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]