#!/usr/bin/perl use strict; # THIS SCRIPT CONCATENATES DATA FOR 1 WEEK OF RELIANT TRUST DATA AND SENDS TO NDM # my $MAIL_ALIAS='my.email.com'; # Mail Alias used for sending emails my $ASL='app-server'; # what the heck is ASL?????????!!!! my @LOG_FILENAMES=('name1.log','name2.log'); my($yyyy,$mm,$dd) = deduct_date_values( timestamp_days_back(1) ); my $abs_log_yesterday = "$0.$dd.log"; sub secsday { return (3600 * 24) } # to give you an idea how far you could consider breaking this up sub deduct_date_values { my $timestamp = shift; $timestamp or die; # expect the 'impossible' require Time::Format; my $date_string = Time::Format::time_format('yyyy_mm_dd',$timestamp); my($yyyy,$mm,$dd) = split( /_/, $date_string ); # make sure $yyyy or die; $mm or die; $dd or die; return ($yyyy,$mm,$dd); } sub timestamp_days_back { my $numdays = shift; $numdays or die; my $then = ( time - ( $numdays * secsday() ) ); return $then; } if ($yesterwday == 5) { # compute last 7 days of file names # cat the files foreach $logfilename (@LOG_FILENAMES) { my $abs_cat_target = "$logfilename.$year$mm$dd"; unlink $abs_cat_target; # in case we run 2x in one day for my $i (5,6,7,8) { for my $days_back (7,6,5,4,3,2,1) { # Number of days to go back for process my($yyyy,$mm,$dd) = deduct_date_values( timestamp_days_back($days_back) ); my $abs_file = "$logfilename.myservername$i\.$year$mm$dd"; $command = "cat $fileext.$ASL$i >> $catfile 2>/dev/null"; if ($debug) { print "WOULD $command\n"; } else { $output = `$command`; }