While I'm away from my network on the weekend, I like to know what's going on. I downloaded the program Snort and it keeps a log of the different goings on. I could VPN to the network, and just look around, but it's more convenient if I let perl send me the the last 25 lines of my log file to my email account at home. Here is how I did it.
use strict; use Net::SMTP; print"monitoring snort log \n"; print " hit q then enter to exit: "; open (fh, "< e:\\snort\\log\\alert.ids") or die "Can't open File"; my @lines = <fh>; my $hours = 0; while (<STDIN> != 'q') { while ($hours < 72) { # hours of updates you want my $timer = 0; while ($timer < 1) { # minutes between the update #Mail Data my $smtp = Net::SMTP -> new('mailserver.mail.com'); #Connect +to a mail server $smtp -> mail( 'sending\@mail.com'); #Sender's name $smtp -> to('receiving\@mail.com'); #Receivers name $smtp -> data(); # Send the header $smtp -> datasend("To: 'receiving\@mail.com\n"); $smtp -> datasend("From: sending\@mail..com\n"); # Send the Body my $x = 0; while ($x < 25 ) { #lines to print my $lines = pop @lines; $x++; print $lines."\n"; $smtp -> datasend($lines); } $smtp -> dataend(); $smtp -> quit; $timer++; $hours++; sleep 3600; } } } close (fh);

I would appreciate a review of this code, I want to make it better. BTW This is a Win32 version, I'm working on a linux version as well.
Many thanks,
Poetic Justice

In reply to While I'm away... by Poetic Justice

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.