While Loop Unix Change Status Inactive

In a text file (PL_SENDEVENT), I have the following line:
 

CHANGE_STATUS INACTIVE

And another file (PL_JOBS) with the following lines:

TEST

TEST1

What I'm trying to do is change the STATUS of TEST and TEST1 to the status
that I specify in the file which is INACTIVE (or IN) in this case. I do not want
the script to exit until both jobs have been verified that they are in an
INACTIVE (IN) status. It is not going well so far. As it stands, it exits
successfully once it sets TEST to INACTIVE and doesn't even check TEST1. If
the jobs are not in an INACTIVE status, I want it to check again until they both
are.

Here’s what I have now:

Code:
cat $PL_DIR/PL_SENDEVENT | while read event status
do
case $event in
CHANGE_STATUS)
cat $PL_DIR/PL_JOBNAME | while read job do
sendevent -E CHANGE_STATUS -s ${status} -J ${job}
done
case $status in
INACTIVE) export ST=IN ;; ON_HOLD) export ST=OH ;; ON_ICE) export
ST=OI ;; TERMINATED) export ST=TE ;; *) echo "Invalid Status!"; exit 1 ;;
esac
rc3=1
while (($rc3 > 0))
do
sleep 5
cat $PL_DIR/PL_JOBNAME | while read job do
$AUTOSYS/bin/autorep -J ${job} -l0 | sed '1,4d' |
if [ `awk '{print $6}'` == ${ST} ]; then echo "Status is set for ${job}!"
rc3=0
fi
done
done ;;

What am I doing wrong?

A: Try replacing the last part with this:

Code:

rc3=1
while (($rc3 > 0))
do
sleep 5
rc7=0
cat $PL_DIR/PL_JOBNAME | while read job do
$AUTOSYS/bin/autorep -J ${job} -l0 | sed '1,4d' | \
if [ `awk '{print $6}'` == ${ST} ]; then echo "Status is set for ${job}!"
(( rc7 += 1 ))
fi
done
[ $rc7 == `wc -l $PL_DIR/PL_JOBNAME` ] && rc3=0

done

Unix

See Also
File Analysing Commands

Have a Unix Problem
Do you have a UNIX Question?

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.