myscript.sh
success=$?
if [ $success -eq 0 ]; then
echo "script successfull"
else
echo "Script failed!!!" | mail -s "Myscript" \ me@somehwere.com
fi
NOTE: myscript.sh must explicitly return a value eg. "return 0" for success or anything else for failure.
Scripts that finish without a return statement return whatever the last statement returns. If you use return within a function, it will just exit the function. (In contrast, the statement exit N exits the entire script, no matter how deeply you are nested in functions.)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.