I need help. I am trying to get this script to send out only one email not multiple emails of the abend. Currently it will send me one then and ther with the first and second one then another email with the first second and third abend and so on. I only want one email sent.
#!/usr/bin/ksh
LIST=/home/B611568/ABC/daren_scripts/temp/tmpfxxx
ERRORDIR=/home/B611568/ABC/error_directory
EMAILFILE=/home/B611568/ABC/daren_scripts/temp/emailfile
echo "There were errors in the following report file :" > $EMAILFILE
echo >> $EMAILFILE
echo "This files have been moved to $ERRORDIR" >>$EMAILFILE
find /home/B611568/ABC/logs/*.rpt -mtime -5 | egrep -v ftplog >$LIST
while read r1
do
grep CompletionCode $r1 >/dev/null 2>&1
#grep severity $r1 | grep "Completion:" >/dev/null 2>&1
if [ $? = 0 ]; then
grep CompletionCode $r1 | grep "CompletionCode: Value=0" >/dev/null 2>$1
#grep severity $r1 | grep "Completion: Value=0" >/dev/null 2>&1
if [ $? = 1 ]; then
echo $r1 >> $EMAILFILE
echo >>$EMAILFILE
#cat $r1 >>$EMAILFILE
mv $r1 $ERRORDIR
for i in `cat /home/B611568/ABC/daren_scripts/emailparm`
do
cat $EMAILFILE | mail -s $r1 $i@xxxxxxx.cccccccccc.org
done
fi
fi
done<$LIST