#!/bin/perl #################### # Subroutines #################### #################### # Declarations #################### # Use the File Statistics Module use File::stat; # Global Variables $tag=0; ################ # Get The Date ################ ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $year += 1900; $mon += 1; # If month is single digit add 0 if($mon < 10) { $mon = 0 . $mon; } # If day is single digit add 0 if($mday < 10) { $mday = 0 . $mday; } # If sec is single digit add 0 if($sec < 10) { $sec = 0 . $sec; } # If minute is single digit add 0 if($min < 10) { $min = 0 . $min; } # Get part of the year $years=substr($year,2,2); ############## # File Paths ############## $drive="PATH HERE"; $compfile="D:\\SERVERANDDIR\\compare$mday$mon$years.txt"; # Files $files=('20050718_0000585.DAT'); #################################################### # Check if its a Bank Holiday, if so exit the system #################################################### # Set Todays Date $tdate = "$mday-$mon-$year"; if( -e "D:\\SERVERANDDIR\\holidays.txt") { open(HOL, "D:\\SERVERANDDIR\\holidays.txt"); }else{ exit; } while() { $holine = $_; chomp $holine; if($tdate eq $holine) { close HOL; exit; } } close HOL; ######################## ## File Flow Script ## ######################## # Check if any of the drive is available - if not exit if( -e $midasdrive) { # Get the date stamp for the file }else { print "No directory listing \n"; exit; } # Check to see if any of the files exist in the Input directory foreach $filename($files) { if( -e "$drive$filename") { use Time::localtime; $datestring = ctime(stat("$drive$filename")->mtime); # Check to see if compare file exists if( -e $compfile) { # If Compare File exists check to see if that filename already exists in the compare file open(CMP,"$compfile"); while() { # Does that filename exist Check for that filename in the ($line) = $_; chomp $line; # Check for the if($line eq "$filename $datestring") { # Then raise the alarm # samefile($filename); system("DO THE EMAIL THING HERE"); $tag=1; } # Else go to the next record in the file next; } # close the CMP file in read mode close CMP; # Thus there is stuff in the compare file but not this record so lets add it to the existing file if($tag=0) { open(CMP,">> $compfile"); print CMP "$filename $datestring\n"; close CMP; } } # Create a New Compare File else { open(CMP,"> $compfile"); print CMP "$filename $datestring\n"; close CMP; } # End of the check to see if that filename exists } # End of the foreach statement - for filenames