I have a shell script that calls on a Perl script to do some file processing. The Perl scripts exits with either a zero or one value. I have the Unix set -e
command at the beginning of my script to abort the script if the Perl script exits with a value of one. I was just wondering if there is any command in Unix that I can use that would execute one command before the script is aborted if the Perl script exits with a one value? Essentially, I want the script to send me an email stating whether the Perl script ran successfully. My code looks like this right now:
#!/bin/bash
set -e
function email_success {
#Some code for the email
}
function email_fail {
#Some code for the email
}
usr/bin/perl perlscript.pl
if [$? -eq 0]; then
email_success
else
email_fail
fi
#More commands to be executed if its successful