use LWP::UserAgent; use CGI qw(header -no_debug); use Net::SMTP; #my $url = 'http://130.119.7.69/Autosubscriptions/URLsub/winzip.log'; my $url = 'https://myweb.server.com/URLsub/some.log'; my $res = LWP::UserAgent->new->request(HTTP::Request->new(HEAD => $url)); my $ServerName = "mySMTP.gateway.com"; my $file="modifiedtest.txt"; # print header; local $\ = "\n"; if ($res->is_success) { # $res->previous && # $res->previous->is_redirect and print 'redirected: ', $res->request->url; $res->last_modified and $modified = scalar(localtime($res->last_modified)); # $res->content_length and print 'size: ', $res->content_length; } else { print $res->status_line; } #read the file content open FILE, $file or die "Couldn't open file: $!"; while (){ $string .= $_; } close FILE; #open(DAT, $file) || die("Could not open file!"); #@data=; print "file data is $string"; print "web file data is $modified"; #check to see if we have latest info if ($modified = $string) { print "the file is the same"; } else { print "proceeding - file is not the same..."; open(DAT,">$file") || die("Cannot Open File"); print DAT "$modified"; close(DAT); $smtp = Net::SMTP->new($ServerName); die "Couldn't connect to server" unless $smtp; my $MailFrom = "monitor\@netvision.net.il"; my $MailTo = "avishay\@mail.com"; $smtp->mail( $MailFrom ); $smtp->to( $MailTo ); # Start the mail $smtp->data(); # Send the header. $smtp->datasend("To: avishay\@mail.com\n"); $smtp->datasend("From: monitor\@netvision.net.il\n"); $smtp->datasend("Subject: There is new file out there!\n"); $smtp->datasend("\n"); # Send the message $smtp->datasend("New file (time stamped at $modified)\n\n"); # Send the termination string $smtp->dataend(); $smtp->quit(); }