There is an equality in my Perl subroutine that appears to be equal but should not be. I suspect there is an easy answer for this, but I'm new to Perl and probably did something I didn't fully understand. As you can imagine, there is more to the Perl code than I'm pasting, but I think the following code snippet should be sufficient to answer.
sub getJobStatus
{
my $ftps = shift;
my $job_name = trim(shift);
LogMessage("**********************************************************************\n");
LogMessage("Getting JES status for job ${job_name}\n");
LogMessage("**********************************************************************\n");
# Note: the dir() method does not seem to listen to the supplied argument, and
# so returns all the jobs known. This is why all files must be parsed.
my @job_files_found_lines = $ftps->dir($job_name)
or die LogMessage ( "Cannot list for job ${job_name} message=$ftps->message()\n");
my $parsed_job_status = '';
my $counter=0;
my @job_status_split = (split /.*\s+(JOB\d+)\s+([A-Z]+)\s+\d*\s+Spool Files/,$job_files_found_lines[$counter]);
my $parsed_job_name=trim($job_status_split[1]);
$parsed_job_status=$job_status_split[2];
my $array_length = scalar @job_files_found_lines;
LogMessage "\narray length=${array_length} expected_job_name=${job_name}\tjob_name=${parsed_job_name}\tjob_status=${parsed_job_status}\n";
while($counter < $array_length && trim($parsed_job_name)!=$job_name) {
@job_status_split = (split /.*\s+(JOB\d+)\s+([A-Z]+)\s+\d*\s+Spool Files/,$job_files_found_lines[$counter]);
$parsed_job_name=trim($job_status_split[1]);
LogMessage "\nexpected_job_name=${job_name}\tjob_name=${parsed_job_name}\tjob_status=${parsed_job_status}\n";
$counter = $counter + 1;
}
if($job_name==$parsed_job_name) {
LogMessage "Current job_name=${job_name} Found ${parsed_job_name} status=${parsed_job_status}\n";
$parsed_job_status=$job_status_split[2];
}
return $parsed_job_status
}
My log result:
Wed Feb 3 08:07:21 2021: ********************************************************************************
Wed Feb 3 08:07:21 2021: Monitoring job status in repeated loop until job is completed (STATUS=OUTPUT)
Wed Feb 3 08:07:21 2021: ********************************************************************************
Wed Feb 3 08:07:21 2021: **********************************************************************
Wed Feb 3 08:07:21 2021: Getting JES status for job JOB21680
Wed Feb 3 08:07:21 2021: **********************************************************************
Wed Feb 3 08:07:21 2021:
array length=19 expected_job_name=JOB21680 job_name=JOB19471 job_status=OUTPUT**
Wed Feb 3 08:07:21 2021: Current job_name=JOB21680 Found JOB19471 status=OUTPUT
Wed Feb 3 08:07:21 2021:
Wed Feb 3 08:07:21 2021: **********************************************************************
Wed Feb 3 08:07:21 2021: Getting JES output and storing file /host-dirs/out/JOB21680.out
Wed Feb 3 08:07:21 2021: **********************************************************************
Please note the line in the log saying 'Current job_name=JOB21680 and Found JOB19471'. If it says found, it these two jobs should be the same. In the code snippet above, please look at trim($parsed_job_name)!=$job_name