I'm a little short on time today, but here's a snip from a shell script we use for CallAPI job launches (this is a job in one instance to launch a job in another). I think it may give you some ideas; feel free to reply with questions & I'll take a look Monday. :smile:
Output from the calling job looks like this...
NOTE: The first RunID output by the API is for the *SCRIPT object.
To ensure GEN_PAYPAL_RELEASE_REQUEST ran, look for a second RunID and success message.
Initiating UC4 CallAPI...
20171109/131841.953 - U3000000 Program 'UC4 Call Interface' version '9.00A114-511' started.
20171109/131849.362 - U3000004 RunID '542707231'
20171109/131849.365 - U0000050 Job GEN_PAYPAL_RELEASE_REQUEST with RunID 0542681803 activated.
20171109/131849.365 - U3000001 Program 'UC4 Call Interface' version '9.00A114-511' ended normally.
UC4 *SCRIPT object ended with 4.
This indicates success! Returning zero!
# Write the API code into a temp file
tempfile="$tempdir/$ts.scr"
echo "Using temp file $tempfile"
echo ":PSET &CALLING_CHAIN_ID# = $parent_chain_id" >> $tempfile
echo ":PSET &CALLING_CHAIN_CLIENT# = &$CLIENT#" >> $tempfile
echo ":SET &JOBID = ACTIVATE_UC_OBJECT($job,,,,,PASS_VALUES)" >> $tempfile
echo ":IF &JOBID = '0000000'" >> $tempfile
echo ": STOP MSG,51,'Failed to start $job !!!'" >> $tempfile
echo ":ELSE" >> $tempfile
echo ": STOP MSG,50,'Job $job with RunID &JOBID activated.'" >> $tempfile
echo ":ENDIF" >> $tempfile
echo ""
# A note about the UC4 output (which can be misleading)
echo "NOTE: The first RunID output by the API is for the *SCRIPT object."
echo "To ensure $job ran, look for a second RunID and success message."
echo ""
echo "Initiating UC4 CallAPI..."
echo ""
# Call the API to start the job
./$CallAPI INI=$inifile $tempfile
# Deal with the error code passed from CallAPI
myErr=$?
echo ""
echo "UC4 *SCRIPT object ended with $myErr."
if [ $myErr -eq 4 ]; then
echo "This indicates success! Returning zero!"
rm $tempfile
(exit 0)
else
echo "This indicates a problem!"
echo "The object $job might not exist, or it might have encountered a FAULT status."
echo "Returning error!"
(exit $myErr)
fi