KB Article #69071
How to monitor CFTUTIL return code?
How to monitor CFTUTIL return code?
Resolution
Here is a solution described by R&D:
Aim : Monitoring CFTUTIL return code for CFT OS/400.
I /Note : The following solution works under QSH.
II /CFT standard environment :
" profil : CFT
" home directory : /home/CFT.
" CFT libraries : CFTPGM1 et CFTPROD1.
III /Steps to execute :
1/ Create a symbolic link for CFTUTIL program :
ADDLNK OBJ('/QSYS.LIB/CFTPGM1.LIB/CFTUTIL.PGM') NEWLNK('/home/CFT/CFTUTIL')
2/ Create a IFS file "/home/CFT/.profile" containing the following instructions :
export PATH=$HOME:$PATH:/usr/bin
export CFTUTIL=/QSYS.LIB/CFTPGM1.LIB/CFTUTIL.PGM
export CFTCAT=CFTPROD1/CAT1
export CFTPARM=CFTPROD1/PARM1
export CFTPART=CFTPROD1/PART1
export CFTCOM=CFTPROD1/COM1
3/ Create a script for test "/home/CFT/script_utl" containing the following instructions:
if [ "$1" = "" ]
then
CFTUTIL
else
CFTUTIL <<END 1>CFTUTIL.out
CONFIG TYPE=CAT,FNAME=$CFTCAT
CONFIG TYPE=PARM,FNAME=$CFTPARM
CONFIG TYPE=PART,FNAME=$CFTPART
CONFIG TYPE=COM,FNAME=$CFTCOM,MEDIACOM=FILE
$*
END
fi
#test return code
retorno=`cat CFTUTIL.out | grep "Code : " | cut -d":" -f2 `
if [ "$(echo $retorno | grep "^[ [:digit:] ]*$")" ]
then
message_error=`cat CFTUTIL.out | grep "Failed" `
echo $message_error
echo $retorno
exit 1
fi
echo "command submitted OK"
4/ Execute script_utl under QSH and trap error return code:
Example : trap an error code occurs when the communication file is full.
If you have a communication file CFTPROD1/COM1 with record capacity = 3 and you execute the following command 3 times, the COM1 file will be full and the CFTUTIL returns an error code = 4 :
./ script_utl SEND PART=BOUCLE,IDF=TEST
8
Result file /home/CFKHUAT/CFTUTIL.out :
CFTU26E SEND _ Error ( Communication media is full)
6:Input :
6:Input :
CFTU00I RETURN _ Correct (CODE=8)
CFTU20I Number of Command(s) 5
CFTU20I Number of error(s) 1
CFTU20I Ending Session on 04/04/2011 Time is 16:38:25
CFTU20I Session active for 0:00:11
Erreur dans la commande
Code : 8
Erreur de type SEVERE