There is a script I wrote in Perl to send an email form of a summary report
for each map. It also makes a hard copy of report.
# ============================================================ Beginning
#
# Perl Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
#
# NAME: WUG_Report.pl
#
# AUTHOR: Steffen Kory, The Goodyear Tire & Rubber Company
# DATE : 7/4/01
#
# PURPOSE: Generates Monthly Report
# Additional Info: v1.1
#
# ============================================================= Packages
#Needed to install NetServer-SMTP for Net::SMTP
use Net::SMTP;
use strict;
# ================================================================= Main
my($mn_time,$mn_now,$mn_then);
$mn_time = time();
$mn_now = Get_Date($mn_time);
# 60*60*24*(The # of days in last month) is the # of seconds to go back
$mn_then = Get_Date($mn_time - (60 * 60 * 24 * Last_Month((localtime
())[4])));
Get_Files($mn_now,$mn_then);
# ================================================================= Date
# Takes time in seconds from 01/01/1970 "epoch" and returns YYYYMMDD
sub Get_Date {
my($gcd_time) = @_;
my($sec,$min,$hour,$mday,$mon,$year);
($sec,$min,$hour,$mday,$mon,$year) = localtime($gcd_time);
$mday = Add_Zero($mday);
$mon = Add_Zero($mon + 1);
$year += 1900;
return ($year . $mon . $mday);
}
# ================================================================ Month
#
sub Last_Month {
my($lm_month,$lm_year) = @_;
my(%lm_days,%lm_leap,%lm_nonleap,$x);
$lm_year += 1900;
@lm_nonleap{0..11} = qw(31 28 31 30 31 30 31 31 30 31 30 31);
@lm_leap{0..11} = qw(31 29 31 30 31 30 31 31 30 31 30 31);
$lm_month -= 1;
if($lm_month != -1) {
for($x = 2000; $x <= 2020; $x += 4) {
if($lm_year != $x) {
%lm_days = %lm_nonleap;
} else {
%lm_days = %lm_nonleap;
}
}
} else {
$lm_month = 11;
for($x = 2000; $x <= 2020; $x += 4) {
if($lm_year != $x) {
%lm_days = %lm_nonleap;
} else {
%lm_days = %lm_nonleap;
}
}
}
return($lm_days{$lm_month});
}
# ================================================================= Zero
# Adds a zero to number
sub Add_Zero {
my($az_value) = @_;
if($az_value <= 9) { $az_value = "0" . $az_value; }
return($az_value)
}
# ================================================================ Files
# Generates output for email and file
sub Get_Files {
my($gf_now,$gf_then) = @_;
my($gf_file,$gf_dir,$gf_command,@gf_text);
# Directory were maps reside
$gf_dir = "C:\\Program Files\\Whatsup\\Production";
# Command Location
$gf_command = "C:\\Program Files\\Whatsup\\";
chdir($gf_command);
opendir(DIR, "$gf_dir");
while(defined($gf_file = readdir(DIR))) {
@gf_text = "";
if($gf_file =~ /\b(.+)\.wup$/) {
open(OUT, "> $gf_dir\\$1-Report.TXT") || die("Could not open
file: $!");
@gf_text = `wugrpt.exe -m\"$gf_dir\\$gf_file\" -t\" $1\"
-r\"summary\" -s$gf_then -e$gf_now`;
Mail_It($1,@gf_text);
print OUT @gf_text;
close(OUT) || die("Could not close file: $!");
}
}
close(DIR);
return();
}
# ================================================================ Email
# Sends report via email. Replace <Your SMTP
Server>,<[EMAIL PROTECTED]>,<[EMAIL PROTECTED]> with your info.
sub Mail_It {
#Name of report: $mi_report text of report: $mi_body
my($mi_report,@mi_body) = @_;
my($smtp);
$smtp = Net::SMTP->new('<Your SMTP Server>'); # connect to an
SMTP server
$smtp->mail('<[EMAIL PROTECTED]>'); # use the sender's
address here
$smtp->to('<[EMAIL PROTECTED]>'); # recipient's address
$smtp->data(); # Start
the mail
# Send the header.
$smtp->datasend("To: steffen_kory\@goodyear.com\n");
$smtp->datasend("From: Whats Up Gold\n");
$smtp->datasend("Subject: $mi_report Report.\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("@mi_body\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP
connection
return();
}
# ================================================================== End
Please visit http://www.ipswitch.com/support/mailing-lists.html
to be removed from this list.
An Archive of this list is available at:
http://www.mail-archive.com/whatsup_forum%40list.ipswitch.com/