7/29/2010 1:47:00 PM
perl 执行一个系统命令(svn info),发一封邮件
use.NET::SMTP;
system("svn info http://x.x.x.x>>num1");
open (FILE1,"num1")||die "Couldn't open num1";
$num1=<FILE1>;#print $num1;
$num2=<FILE1>;#print $num2;
$num3=<FILE1>;#print $num3;
$num4=<FILE1>;#print $num4;
$num5=<FILE1>;#print $num5;
$num6=<FILE1>;#print $num6;
my ($name,$a) = splIT(//:/, $num5);
system("svn info http://x.x.x.x>>num1");
open (FILE1,"num1")||die "Couldn't open num1";
$num1=<FILE1>;#print $num1;
$num2=<FILE1>;#print $num2;
$num3=<FILE1>;#print $num3;
$num4=<FILE1>;#print $num4;
$num5=<FILE1>;#print $num5;
$num6=<FILE1>;#print $num6;
my ($name,$a) = splIT(//:/, $num5);
system("svn info
http://x.x.x.x>>num2");
open (FILE2,"num2")||die "Couldn't open num2";
$num1=<FILE2>;#print $num1;
$num2=<FILE2>;#print $num2;
$num3=<FILE2>;#print $num3;
$num4=<FILE2>;#print $num4;
$num5=<FILE2>;#print $num5;
$num6=<FILE2>;#print $num6;
my ($name,$b) = split(//:/, $num5);
open (FILE2,"num2")||die "Couldn't open num2";
$num1=<FILE2>;#print $num1;
$num2=<FILE2>;#print $num2;
$num3=<FILE2>;#print $num3;
$num4=<FILE2>;#print $num4;
$num5=<FILE2>;#print $num5;
$num6=<FILE2>;#print $num6;
my ($name,$b) = split(//:/, $num5);
if (1){
notify();
close FILE1;
close FILE2;
}
sub notify()
{
my $subject = subvision;
my $message = "Currently local subversion number is $a Currently Remote subversion number is $b";
my $mailhost = mial server name;
$smtp = Net::SMTP->new($mailhost);
#$mailto is recipient of the email
$mailto = " x@x.x.x";
#$mailfrom is sender of the email
$mailfrom = " x@x.x.x";
$smtp->mail($mailfrom) or $emailstatus = 0;
$smtp->to($mailto, $mailcc) or $emailstatus = 0;
$smtp->data() or $emailstatus = 0;
$smtp->datasend("From: $mailfrom/n") or $emailstatus = 0;
$smtp->datasend("To: $mailto/n") or $emailstatus = 0;
$smtp->datasend("Cc: $mailcc/n") or $emailstatus = 0;
$smtp->datasend("Subject: $subject/n") or $emailstatus = 0;
$smtp->datasend("/n") or $emailstatus = 0;
$smtp->datasend("$message/n/n") or $emailstatus = 0;
$smtp->datasend() or $emailstatus = 0;
$smtp->quit() or $emailstatus = 0;
}
unlink num1;
unlink num2;
notify();
close FILE1;
close FILE2;
}
sub notify()
{
my $subject = subvision;
my $message = "Currently local subversion number is $a Currently Remote subversion number is $b";
my $mailhost = mial server name;
$smtp = Net::SMTP->new($mailhost);
#$mailto is recipient of the email
$mailto = " x@x.x.x";
#$mailfrom is sender of the email
$mailfrom = " x@x.x.x";
$smtp->mail($mailfrom) or $emailstatus = 0;
$smtp->to($mailto, $mailcc) or $emailstatus = 0;
$smtp->data() or $emailstatus = 0;
$smtp->datasend("From: $mailfrom/n") or $emailstatus = 0;
$smtp->datasend("To: $mailto/n") or $emailstatus = 0;
$smtp->datasend("Cc: $mailcc/n") or $emailstatus = 0;
$smtp->datasend("Subject: $subject/n") or $emailstatus = 0;
$smtp->datasend("/n") or $emailstatus = 0;
$smtp->datasend("$message/n/n") or $emailstatus = 0;
$smtp->datasend() or $emailstatus = 0;
$smtp->quit() or $emailstatus = 0;
}
unlink num1;
unlink num2;