OK, tried all this out and am running into a problem.  If I use your script as 
written, the exact phrase 'ls --full-time $watchdir | md5sum' is the only thing that 
gets written into the sumfile.  I've tried a few things to change the syntax (switch 
the option and the $watchdir, added full quotes to the $watchdir, and so forth) but 
the effect is the same.  What am I doing wrong?

Thanks again!

Stuart


-----Original Message-----
From: Anthony E. Greene [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 13, 2003 12:30 PM
To: [EMAIL PROTECTED]
Subject: Re: program to monitor directory changes (new files) and send
e-mail


That is exactly it. For the record, here is a commented version, as I 
would have written it if I were implementing it on my own server:


#!/bin/sh
#
# Notify the admin if a directory's contents has changed.
#

# The directory to monitor.
watchdir='/path/to/ftpdir'

# Who gets notified of changes. This may be a
# comma-delimited list, but no spaces.
recipient='[EMAIL PROTECTED]'

# The file that holds an md5sum of the directory
# listing, as of the last time it was changed.
sumfile='/path/to/sumfile'

## End of settings ##

# Get the previous md5sum of the directory listing.
olddirsum=`cat $sumfile`

# Get the current md5sum of the directory listing. Use the
# --full-time option to avoid errors based on ls changing the
# displayed date format based on the age of the file.
newdirsum=`ls --full-time $watchdir | md5sum`

# Compare the previous md5sum to the current md5sum.
if [ "$newdirsum" != "$olddirsum" ]; then
   # The directory listing changed.
   # Send notification message.
   ls $watchdir | mail -s "Updated dirlist: $watchdir" $recipient

   # Update the summmary file with the current md5sum.
   echo "$newdirsum" > "$sumfile"
fi



-- 
Anthony E. Greene <mailto:[EMAIL PROTECTED]>
OpenPGP Key: 0x6C94239D/7B3D BD7D 7D91 1B44 BA26 C484 A42A 60DD 6C94 239D
AOL/Yahoo Chat: TonyG05   HomePage: <http://www.pobox.com/~agreene/>
Linux. The choice of a GNU generation. <http://www.linux.org/>



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list



-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to