chris01010
Programmer
I have written the below PERL script to reprocess messages from a failure queue.
It basically browses all the messages in the failure queue to individual files in a directory and then scans those files to determine the originating queue. The script will then move each message in turn from the failure queue to their respective originating queue.
The problem I currently have is that if the value meets the FROM_BOB condition then any subsequent messages gets assigned the same $queue value regardless.
Any ideas?
It basically browses all the messages in the failure queue to individual files in a directory and then scans those files to determine the originating queue. The script will then move each message in turn from the failure queue to their respective originating queue.
The problem I currently have is that if the value meets the FROM_BOB condition then any subsequent messages gets assigned the same $queue value regardless.
Code:
#!/usr/bin/perl
use strict;
my $count;
my $queue;
my $var;
my $tancCheck;
my $numOfFilesTMP;
my $numOfFiles;
my $suffix;
browseMsgs();
messageMove();
exit(0);
sub browseMsgs
{
`rm -f MQSIFailMsgs*`;
`./mqcapture -f parmcapt -o MQSIFailMsgs -d`;
}
sub messageMove
{
$count=0;
`rm -f output`;
$numOfFilesTMP=`ls MQSIFailMsgs* | wc -l`;
$numOfFiles = $numOfFilesTMP - 1;
if ( -z './MQSIFailMsgs' ) {
print "MQSIFailMsgs is empty!\n";
}
if ( $count == 0 ){
$suffix = "";
} elsif ( $count != 0 ){
$suffix = $count;
}
while ( $count <= $numOfFiles )
{
open FAILED, "./MQSIFailMsgs$suffix";
while(<FAILED>)
{
my $queue;
my $tancCheck;
##local $/ = undef;
$var = $_;
($var) =~ m/OPT_APP_GRP(.*)OPT_MSG_TYPE/s;
print "line 48 $1\n";
if ($1 eq " FROM_BOB ") {
open NEXTCHECK, "./MQSIFailMsgs$suffix";
$tancCheck =$_;
($tancCheck) =~ m/OPT_MSG_TYPE(.{7})/s;
print "line 55 $1\n";
if ($1 eq " A_ABCD") {
$queue = "FROM_BILL";
} else {
$queue = "FROM_BOB";
}
close NEXTCHECK;
print "line 57 $queue\n";
} elsif ($1 eq " SANDRA ") {
$queue = "FROM_SANDRA_PP";
print "line 60 $1\n";
} elsif ($1 eq " BEN_MSGS ") {
$queue = "FROM_BEN";
print "line 63 $1\n";
} elsif ($1 eq " FROM_SUSAN ") {
$queue = "FROM_SUSAN";
print "line 66 $1\n";
} elsif ($1 eq "") {
print "line 68 $1\n";
$queue ="noQueue";
}
if ($queue eq "noQueue") {
print "no queue defined!\n"; exit(1);
}
`/a/b/c/d/e/f -IMQSI_FAIL -o$queue -mQM_F -L1`;
$count = $count + 1;
print "$queue\n";
open FILE, ">>./output\n";
print FILE "Message number $count has been put to $queue\n"; close FILE;
}
close FAILED;
}
}
Any ideas?