I am in trouble. I can get inside my condition test inside a loop :
I am in ksh (solaris)
while read file
do
<commande to retrieve file> >> ${LOG_RETRIEVE_FILE.log}
msg_err=$(cat ${LOG_RETRIEVE_FILE.log} | grep "error retrieve")
if [ ${msg_err} -gt 0 ] ; then
<sendmail>
exit 1
fi
done
while read file
do
<commande to retrieve file> >> ${LOG_RETRIEVE_FILE.log} #what exactly you doing here?
msg_err=`grep -c "error retrieve" $LOG_RETRIEVE_FILE.log`
echo $msg_err
if [ "$msg_err" -gt "0" ] ; then
echo "send email"
exit 1
fi
done < inputFile #where is your input for the while loop ?
msg_err=$(cat ${LOG_RETRIEVE_FILE.log} | grep "error retrieve")
if [ ${msg_err} -gt 0 ] ; then
msg_err will most likely be a string, not a number, something along error retrieve [a number maybe...?]
So you can't use -gt to test if error retrieve [something] is greater than 0
Can you post some lines of your log file? (namely those with 'error retrieve' )
I found the error on my script. As I check the return code while connecting to the archive system to retrieve files on the top of the code, I was unable to get inside of the condition in my loop.
I am trying to find a way to solve this on my own, but thanks again for your help.