On Wed, 9 Jun 2004, Charlie Schluting wrote:

> modify to taste from here:
> http://schluting.com/count

Thanks, Charlie. Using your blueprint, this is what I came up with. I 
have a LOT of mailboxes, so I limited the search to a few. I just 
needed notification of new mail. Here's what I came up with. I run it 
in the background.

Regards,
Paul

---

#!/bin/sh

MAILDIR=$HOME/mail
GREP=/bin/grep
TOTAL_COUNT=0
MAILBOXES="Musicians OurPlace [BLUE] [PDXLUG] [SYSTEM]"
OLDMAILDIR=""

while [ 0 = 0 ]; do
cd $MAILDIR
MAILIN=""
for each in /var/mail/$USER $MAILBOXES
do
  if [ -f $each ]; then
    totalCount=`$GREP "^From " $each | wc -l`
    readCount=`$GREP "^Status: RO" $each | wc -l`
    unreadCount=`expr $totalCount - $readCount`
      if [ $TOTAL_COUNT -eq 0 ]; then
        TOTAL_COUNT=`expr $TOTAL_COUNT + $unreadCount`
      fi
      if ! [ $unreadCount -eq 0 ]; then
        if [ "$each" = "/var/mail/$USER" ]; then each="INBOX"; fi
        MAILIN="$MAILIN $each"
      fi
  fi
done

if ! [ "$MAILIN" = "" ]; then
 if ! [ "$MAILIN" = "$OLDMAILIN" ]; then
   OLDMAILIN=$MAILIN
   echo "You have new mail in:$MAILIN"
 fi
fi

sleep 60
done

---                  _
Paul F. Lankow      -o)
Linux enthusiast    /\\
www.fedora.com     _\_v

_______________________________________________
PDXLUG mailing list
[EMAIL PROTECTED]
http://pdxlug.org/mailman/listinfo/pdxlug

Reply via email to