File monitoring script

Team,

Attached 2 scripts for your validation(main script,mail script)

Problem description:

When its red it should wait for 10 seconds and then send a mail. If not red it should not send the mail

i have done the below changes in the main script:

 if [ $DIFF -gt 15 ]
        then
                if [ $DIFF -gt 30 ]
                then
                        COLOR="red"
 echo "<tr><td>$name</td><td> $timeE </td><td> $timeA </td><td bgcolor=$COLOR> $DIFF </td></tr>" >> $OUTFILE
sleep 10 
mail.sh

(I have hashed out the(main script)rest in-order to achieve my desired result)

But the problem is when i run the script with the above modification.
It sends me a mail with a blank(html) format. So.. How do i stop this blank mail.. ?

Request you to please suggest as to how to resolve the problem

Many thanks!

P.S: Please dont treat this as assignment task!

Regards
Whizkidash

Guys...

Any try on the below query asked

        if [ $DIFF -gt 15 ]

        then

                if [ $DIFF -gt 30 ]

                then

                        COLOR="red"
			echo "<tr><td>$name</td><td> $timeE </td><td> $timeA </td><td bgcolor=$COLOR> $DIFF </td></tr>" >> $OUTFILE
			sleep 10 
			mail.sh

                else

                        COLOR="#FF8000"
		        echo "<tr><td>$name</td><td> $timeE </td><td> $timeA </td><td bgcolor=$COLOR> $DIFF </td></tr>" >> $OUTFILE

                fi

        else

                        COLOR="amber"
		        echo "<tr><td>$name</td><td> $timeE </td><td> $timeA </td><td bgcolor=$COLOR> $DIFF </td></tr>" >> $OUTFILE

        fi


Thanks mate,

When i do the below changes.

If there are no red entry.. i receive a mail with a blank format.
How do i stop this now..?

Conclusion:I need to receive mail only when there are errors(red).If not then no mail should be sent/received

I hope its more clear now!.

Regards
Whizkidash

I think your code is not very economically phrased. Suppose you want to change the line starting with "echo": how often would you have to apply that change, hm?

As a rule of thumb keep everything out of a control structure which can be left out. Like this:

if   [ $DIFF -gt 30 ] ; then
     COLOR="red"
elif [ $DIFF -gt 15 ] ; then
     COLOR="#FF8000"
else
     COLOR="amber"
fi
echo "<tr><td>$name</td><td> $timeE </td><td> $timeA </td><td bgcolor=$COLOR> $DIFF </td></tr>" >> $OUTFILE

if [ $DIFF -gt 30 ] ; then
     sleep 10 
     mail.sh
fi

I hope this helps.

bakunin