[SC.LUG] a simple script

Simeon Farrington sub_mail at farrin.org.uk
Wed Jan 25 23:55:56 GMT 2006


OK guys I'm not remotely a coder by any stretch of the imagination as you 
will see below.

What I'm trying to do is to effectly create a mail notification "beep" as 
at present procmail runs off with my messages, so I can't do this via the 
mail command (at least, "I" couldn't). Anyway, this works correctly from a 
cron job if I have mail, but if I don't, cron issues an error which gets 
sent as a mail message. Hence I end up with a notification that I have an 
error message which wasn't quite what I had in mind. Basically can 
somebody explain how I deal with an if statement that compares something 
with nothing. I tried this in line 6 but it breaks the if statement:

#!/bin/sh

cat ~/mail/Inbox | grep "To: " > /tmp/chk
CHK="To:"
echo `cat /tmp/chk | cut -c 1-4 | tail -1` > /tmp/chk2
if [ `cat /tmp/chk2`  == "" ]; then
exit 0
elif [ `cat /tmp/chk2`  = "$CHK" ]; then
beep -f 400
fi

I appreciate the coding above is horrible and will probably give people 
nightmares on the list. However, one day I hope to know what I'm doing :)

Simeon



More information about the SC mailing list