In production I need to pass an exit code from a script that is being called 3 or 4 layers deep. I've created test scripts to play with it until I get it right. As you can tell, this is not my normal job. Perhaps I should have entered this in UNIX for Dummies section. Anyway, I keep losing the value of my variable. Can you please help? Thanks.
SCRIPT 1
#!/usr/bin/ksh
echo 'in test1'
EXITSTATUS=$?
if test2 [${EXITSTATUS} -ne 0 ]
then
exit ${EXITSTATUS}
fi
SCRIPT 2
#!/usr/bin/ksh
echo 'in test2'
EXITSTATUS=$?
if test3 [${EXITSTATUS} -ne 0 ]
then
exit ${EXITSTATUS}
fi
SCRIPT3
#!/usr/bin/ksh
echo 'in test3'
EXITSTATUS=99