Try something like this--it does the mtime >= atime comparison for you.

#!/bin/bash
#
# usage: $0 <my-biff-file>
#
while /bin/true; do { 
  VALUE=`echo $1 | perl -lane '{\
        use File::stat;\
        $a=stat($_); \
        if ( $a->mtime() >= $a->atime() ) {\
        print "new"; exit;\
        } else {\
        print "old"; exit;};\
        }'`
  if test $VALUE = "new" ;
  then
        # play a sound
  else
        # do something else
  fi

  sleep 30 ;

} ; done





On Sun, Apr 08, 2001 at 05:06:19PM -0400, Rich Lafferty wrote:
> On Sun, Apr 08, 2001 at 10:34:38PM +0200, Johannes Huettemeister 
>([EMAIL PROTECTED]) wrote:
> > 
> > Hi, 
> > I got the same prob. All mail checkers seem to work with the spool
> > file, so they only check if the file is == 0. But you need a proggie
> > that checks if the size of the mailbox or mailfolder has changed.
> 
> Er, no. You want to check if the mtime of the file is greater than the
> atime. This is also how most mail-checkers like biff work. I don't
> know of any mail checker that indicates that new mail has arrived
> only if the mailbox was empty beforehand.
> 
> To the original poster: If you're using procmail to sort your incoming
> mail, you may as well have procmail launch the command to play the
> sound as well.
> 
>   -Rich
> 
> -- 
> ------------------------------ Rich Lafferty ---------------------------
>  Sysadmin/Programmer, Instructional and Information Technology Services
>    Concordia University, Montreal, QC                 (514) 848-7625
> ------------------------- [EMAIL PROTECTED] ----------------------

-- 


   "Babbage himself acknowledged Jacquard's precedence: when
   he presented the concept for his Analytical Engine at the
   Turin conference, he brought  with him a silk portrait of
   Jacquard  that  had been  produced  by an  automatic loom
   programmed  by no fewer than twenty-four thousand  cards. 
   Even by today's standards, that's a lot of code."
                                - Jim Holt,
                                  The New Yorker 2001/3/5


Reply via email to