Emailautoreply: shellperl1:
#!/bin/sh #get current time date>ping.txt #ping cmd test ping -c 5 portal.uniforce.net>>ping.txt #get HTML code wget -l 2 http://portal.uniforce.net #compare diff index.html index.html.1>different cat different>>ping.txt if test -s different; then #HTML wrong perl perl2 else #HTML right perl perl1 fi #refresh rm -f index.html
|
#!/usr/bin/perl
open (PING,"ping.txt")or die "cannot open ping.txt$!\n"; $ping=<PING>."\n";
use MIME::Lite; use Net::SMTP;
### Adjust sender, recipient and SMTP mailhost
my $from_address = 'seven.zhang@uniforce.net'; my $to_address = 'leif.liang@uniforce.net,op@uniforce.net,seven.zhang@uniforce.net'; my $mail_host = 'nxserver.sh.uniforce.net'; my $result='portal.uniforce.net can be access'; ### Adjust subject and body message
my $subject = 'uniforce portal check';
### Adjust the filenames
my $my_file_html = 'index.html'; my $your_file_html = 'index.html';
### Create the multipart container
$msg = MIME::Lite->new ( From => $from_address, To => $to_address, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n";
### Add the text message part
$msg->attach ( Type => 'TEXT', Data => $ping.$result, ) or die "Error adding the text message part: $!\n";
### Add the html file
$msg->attach ( Type => 'HTML', Path => $my_file_html, Filename => $your_file_html, Disposition => 'html' ) or die "Error adding $file_html: $!\n";
### Send the Message
MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send;
perl2:
|
#!/usr/bin/perl
open (PING,"ping.txt")or die "cannot open ping.txt "; $ping=<PING>."\n";
use MIME::Lite; use Net::SMTP;
### Adjust sender, recipient and SMTP mailhost
my $from_address = 'seven.zhang@uniforce.net'; my $to_address = 'leif.liang@uniforce.net,op@uniforce.net,seven.zhang@uniforce.net'; my $mail_host = 'nxserver.sh.uniforce.net'; my $result1='portal.uniforce.net cannot be access';
### Adjust subject and body message
my $subject = 'uniforce portal check';
### Adjust the filenames
my $my_file_html = 'index.html'; my $your_file_html = 'index.html';
### Create the multipart container
$msg = MIME::Lite->new ( From => $from_address, To => $to_address, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart container: $!\n";
### Add the text message part
$msg->attach ( Type => 'TEXT', Data => $ping.$result1, ) or die "Error adding the text message part: $!\n";
### Add the html file
$msg->attach ( Type => 'HTML', Path => $my_file_html, Filename => $your_file_html, Disposition => 'html' ) or die "Error adding $file_html: $!\n";
### Send the Message
MIME::Lite->send('smtp', $mail_host, Timeout=>60); $msg->send;
|
阅读(215) | 评论(0) | 转发(0) |