#!/usr/local/bin/perl use warnings; use strict; use POSIX 'mktime'; use POSIX 'strftime'; my @now = localtime(); my $todaysday = strftime("%d" , localtime()); my $thismonth = strftime("%b" , localtime()); my $year = strftime("%Y" , localtime()); my $SERVICEDESK="servicedesk"; my $CLIENTFILE = strftime("%Y_backup_report.csv" , localtime()); my $Temp = strftime("C:\\temp\\Unknown_servers%d%b.txt" , localtime()); my $already_there = 0; open my $mon, '<', "c:\\DBR_$year\\$thismonth\\Monthly_backup_report\\$thismonth$CLIENTFILE" or die "read file $!\n"; while ( defined ( my $line = <$mon> ) ) { my ( $date ) = split ',', $line; if ( $date eq "$todaysday $thismonth $year" ) { print "\ file has already been updated today"; $already_there++; last; } } close $mon; if ( ! $already_there ) { open my $day, "c:\\DBR_$year\\$thismonth\\Failures_output\\$todaysday$thismonth$SERVICEDESK.csv" or die " 22read file $!\n"; open $mon, '>>', "c:\\DBR_$year\\$thismonth\\Monthly_backup_report\\$thismonth$CLIENTFILE" or die "33 write to file $!\n"; <$day>; # get past header while ( <$day> ) { print { $mon } $_; print " $thismonth$CLIENTFILE\n"; print " Has also been updated with today's failures \n"; print " Please update the Resolutions when they are received \n\n"; print " *************************************************************\n"; } close $day or die "Could not complete writing to monthly file: $!\n"; close $mon or die "Could not complete writing to monthly file: $!\n"; } exit $already_there; ### call email perl #################### unless ( -z "$Temp" ) { print "File has something in it\n"; exec "c://testscripts//email.pl" or die "problem with email.pl"; } #########################################