I'm required to write a simple shell script that when it runs it writes the output which is a simple barcode to a tmp flat file which I can do the bit I'm struggling with...
The next time it runs I need to check the tmp output file to see if that barcode is in the output file and if it is send out an email alert
Any help gratefully received
When you say "barcode" what exactly do you mean? If you want ti check the file exists then it's likely to be asimple shell test - checking the contents will be a bit more involved.
Here is a code snippet, from a shell script you should be able to modify to suit quite easilly. But as you haven't shown me what you've tried or your code I can't be more precise.
### Adjust this for your environment
MAILLIST="<enter your mail address here multiple address saparated with comma(,)>"
EXIST=`grep ${BARCODE} ${TEMPFILE}`
if [ $EXIST = 0 ]
then
echo "The Barcode ${BARCODE} already exists." >/tmp/outmail
cat /tmp/outmail|mailx -s "Barcode Already Exists" $MAILLIST
else
echo "New Barcode ${BARCODE} created." >/tmp/outmail
cat /tmp/outmail|mailx -s "New Barcode Created." $MAILLIST
fi
Do I get you right that the new bar code string is in a file called failed_list_check and should be tested for existence in a "history" file failed_list , and, if found, send a mail? If so, try