Hi all,
Maybe my question is too simple but till now i couldn't figure about a solution
I have a bash script scheduled in cron:
<cron time parameters> my_script.sh > result.log 2>&1
By this way i can have standard output and standard error in my result.log file
Now i want my script to alert me when some critical errors occurs.
For example, if i want to do a check like that:
ls $dir
if [ $? -ne 0 ]
then
echo "ALERT ALERT ALERT" >>fileAlert.log
fi
But as i redirected the stderror i can't catch it enymore with $?, isn't it?
When i launch the script, by commmand line:
my_script.sh > results.log 2>&1
i get the error:
"Ambiguous output redirect"
I can do something about that? Or maybe i miss something else?
For sure i can use AWK and similiar to parse output of each test in the script, but i would like to use the exit status of each command.
Is it possible??
thanks in advance!
