[Tfug] Perl Scripts and Email
Robert Hunter
hunter at tfug.org
Wed Jul 12 00:31:52 MST 2006
> I'm working on some Perl scripts for work - the script greps through
> logfiles and if certain strings are matched (eg - "virus found", "spyware
> found", etc) they are to send me an email with the relevant client data
> (IP
> address, client info, date/time). I know I can use perl and sendmail to
> shoot me an email with this information, but I need the script to work on
> Windows machines as well. Is this possible?
>
> I'm doing the research now, but I was curious if anyone else had done this
> before and knew the answer....
>
> Thanks again
>
> -Chris
Sure, assuming you have Perl installed on the Windows machines ( i.e.
ActiveState, or via cygwin, or whatever ).
On a Unix machine you could simply do something like:
open( MAIL, "| mail -s $subject $recipient" ) or die;
print MAIL "resistance is futile!\n";
Assuming you don't have a command-line mail program on your Windows
machines, you can find a package on CPAN ( like Mail::Sender ) that will
do what you need.
For help on using CPAN, do a:
perldoc CPAN
If I recall correctly, the ActiveState distribution comes with it's own
package manager, PPM.
--
Rob
More information about the tfug
mailing list