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]

Reply via email to