use strict; use warnings; use win32::ole; use Date::Calc; use Mime::Lite; my @modify; my $modify_seconds; my $sleep_count = 0; my $final_time; my $a_final_denis = '//10./Automated Reports/Final_Denis_Test.pl'; my $backup_report = '//163./planning/Logistics/Programs/Chicago WIP Query Tools/Final_Denis_Test.pl'; &checkfile ($a_final_denis); sub checkfile { my $file = shift(@_); my $flag = 1; my $sleep_count = 0; while ($flag){ if (-e $file) { @modify = stat ($file); $modify_seconds = $modify[8]; print "$file\n"; if (&checktime ($modify_seconds, $file)) { $flag = 0; } else { $sleep_count++; if ($sleep_count > 3) {&late_file} sleep(3); } } else { print "File not found\n"; goto F_End; } } } sub checktime { my $modify_seconds = shift(@_); my $file = shift(@_); my $local_time = localtime($modify_seconds); my $current_tm = time(); $final_time = $current_tm - $modify_seconds; print "$final_time\n"; if ($final_time >= 80000) { return 0; }else { goto Q_End; } } sub late_file { open $backup_report; print "File Is Late In Updating"; exit 1; } ########################################### F_End: open $backup_report; my $msg_end = MIME::Lite->new( From =>'rzcj60@freescale.com', #who is sending the email To =>'rzcj60@freescale.com', # who is receiving the email Subject =>'Final Denis Report Innactive', # subject of the email Type =>'multipart/mixed' #what type of email (it is like this since it is text and attachment) ); $msg_end->attach(Type =>'TEXT/Plain', #what is being attached Data =>"Computer running Final_Denis automated report is not active" #The body of the email ); MIME::Lite->send('smtp', "freescale.net", Timeout=>60); #smtp routing information for email $msg_end->send; # send function exit; Q_End: print "File Updated"; exit;