Hi All,
I have a parent shell script A and a child shell script B.
1). If a command i.e a mysqdump fails in shell script B fails then I trap the error with this code
if [[ $?>0 ]]
then func_exit "Failed to export the cleaned DB1.${MYDBNAME} database to the ${MYARCHIVEDIR} directory"
else
func_logwriter "Successfully exported the cleaned DB1.${MYDBNAME} database to the ${MYARCHIVEDIR} directory"
fi
the func_exit writes various messages to log and calls exit 1
2). The parent script A called script B and also monitors the return status in the same way as above. However, the func_exit possess the following code:
function func_exit()
{
func_logwritertimestamp
func_logwriter "##########"
func_logwriter "# APPLICATION ERROR"
func_logwriter "##########"
func_logwriter "$1"
func_logwriter "Aborting the Alpha process"
func_logwriter "##########"
SUBJECT=${ADMINSUBJECT}." Failure - Details Attached"
TO=${ADMINMAIL}
/usr/bin/mailx -s "${SUBJECT}" ${TO} < ${LOGSDIR}/$(date +"%Y-%m-%d")_alpha.log
exit 1
}
For some reason the func_exit in script A is not being called on a failure in script B. Hence I don't get an email.
Please could anyone advise if the exit status propagation between the parent and child script is correct. I am using Debian.
Many thanks for your help.