Hi erezschatz,
Thanks for your response but the above code is giving me a wrong output because in file currently i have 10 jobs and all jobs were successfull completed but your code is giving me output like
Total successfull jobs = 10
Total failed jobs = 9
Name of Failed jobs are
More over the provided code is not a desired one because i have a file which contains three columns start date (the date is sotored in file as a string) job status and job name further more that file have not such kind of functionality to store the status of failed jobs the file only contains the status of successfull jobs or the jobs completed with warnings. let me explain the file in more details.
for example i have 100 jobs which runs between every friday,saturday and sunday now the out put of file will be
28 Jan 2011 | Completed | ABC
28 Jan 2011 | Completed | DEF
28 Jan 2011 | Completed | GHI
28 Jan 2011 | Completed with warnings | JKL
28 Jan 2011 | Completed | LMN
28 Jan 2011 | Completed | OPQ
28 Jan 2011 | Completed with warnings| RST
21 jan 2011 | Completed | UVW
21 jan 2011 | Completed | XYZ
21 jan 2011 | Completed | MVU
21 jan 2011 | Completed | QPO
28 Jan 2011 | Completed | CBD
29 Jan 2011 | Completed | JHI
29 Jan 2011 | Completed | KOP
29 Jan 2011 | Completed | YTU
29 Jan 2011 | Completed with warnings| IYR
29 Jan 2011 | Completed | ERT
29 Jan 2011 | Completed | WEQ
22 Jan 2011 | Completed | ASR
22 Jan 2011 | Completed | QWY
22 Jan 2011 | Completed | CXZ
23 Jan 2011 | Completed | FNB
23 Jan 2011 | Completed | VXR
23 Jan 2011 | Completed | CDS
30 Jan 2011 | Completed with warnings| XPO
30 Jan 2011 | Completed | JKI
30 Jan 2011 | Completed | FDP
30 Jan 2011 | Completed | MSR
30 Jan 2011 | Completed | ETP
Now if we look into the file we have jobs which did not run over the weekend like below jobs
21 jan 2011 | Completed | UVW
21 jan 2011 | Completed | XYZ
21 jan 2011 | Completed | MVU
21 jan 2011 | Completed | QPO
22 Jan 2011 | Completed | ASR
22 Jan 2011 | Completed | QWY
22 Jan 2011 | Completed | CXZ
23 Jan 2011 | Completed | FNB
23 Jan 2011 | Completed | VXR
23 Jan 2011 | Completed | CDS
The script which is stroes the information of jobs shows the status of last successfull run and that script doesnot stores the information of failed jobs and only display the last run status like above i have defined for 21 jan, 22 jan and 23 jan
What i want to do
Because the file stores the date as a string when i will read file through perl
first i will split a string on | base
After that the first array string [0] which is date would be converted in a date
After converting the string in to a date i want to compare it with the current system or the date between friday saturday and sunday it the string[0] have the date equals to the date of friday , saturday and sunday's date then its mean the job was successfully completed and also i want to add 1 in the total of successfull jobs
And If the string[0] date is not equal to the date between friday, saturday and sunday's date then its mean the job was not run then in such cases i want to add 1 in the failed jobs and also i want to get the names of failed jobs so that i will be notified that these numbers of jobs were failed
The output would be look like
Total Successfull jobs = 90
Total failed jobs = 10
Name of jobs are
UVW
XYZ
MVU
QPO
ASR
QWY
CXZ
FNB
VXR
CDS
so far i have written the following code please help me out to finish this
#!/usr/local/bin/perl
use strict;
use warnings;
use config;
use HTTP::Date qw(parse_date);
#use Date::Manip::Date;
my @values;
my $values;
&ReadFile();
sub ReadFile
{
# my $strFile = (@_)[0];
my $strFile = 'C://report.txt';
my $i =0;
#print "$strFile\n";
open (CONFIGFILE, "$strFile") || die ("Could not open file!");
while (<CONFIGFILE>)
{
chomp;
next if /^\s*$/;
my $strLine = $_;
my $strLine2 = trim($strLine);
my @values = split (' \|\ ',$strLine2) ;
print parse_date($values[0]); print"\n";
foreach my $val (@values) {
print "$val\n";
}
print "\n";
}
close (CONFIGFILE);
}
# Perl trim function to remove whitespace from the start and end of the string
sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}
Thanks in advance