mailx in kornshell script passing return code to CA-Unicenter

I have a KornShell script that has successfully been scheduled through Cron. We are in the process of changing over from Cron to using CA-Unicenter. To negative test the script I put a bad return code in. At the bottom of the script an e-mail is sent using mailx and then the return code is set using "exit 2". However, CA-Unicenter gets a zero return code back. If I comment out the mailx code, then CA-Unicenter will show up with a return code of 2. My assumption is that the mailx command ends with a zero return code and CA-Unicenter gets it and assumes its from the KornShell script. Here's the piece of code in question:

CENTMSGRC=2
print $CENTMSGRC >> /appl/cmddba/bin/job.log

mailx -s "$subject" "$MAILTO" </appl/cmddba/bin/job.log

print $CENTMSGRC >> /appl/cmddba/bin/job.log

exit $CENTMSGRC

Do you have any idea if my theory is correct? And if it is, do you know a solution to my problem besides creating another Script that will just send the e-mail message and have the script executed after the first one.

Thanks,
Connie

We have discovered that there is a setting within CA-Unicenter that will fix this problem. The following 2 configuation changes where made in CA-Unicenter:

enfcontrol JOB TRIGGER EXITMAIN
instructs CAIENF to consider a job as completed when the main process of the job has completed. We have used this for jobs such as starting a database, the database pid remains active, yet the script that started them can end.

enfcontrol JOB RC EXITMAIN
The control option JOB RC indicates that the exit return code presented by CAIENF to the Unicenter-TNG Workload Management component is the exit code of the main process (shell script).

So essentially CA-Unicenter has been configured to only accept the exit code from the main process script.

Connie
:cool: