Douglas, Stuart wrote:
> 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
The quotes around the ls --full-time $watchdir | md5sum are backward tics
(apostrophes) on my keyboard they are under the ~ sign.  They mean to
execute the command and, in the script, set newdirsum to the result.

You could also the following syntax, which I prefer:
newdirsum=$(ls --full-time $watchdir | md5sum)

JMF
> 
> 
> -----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
This E-mail message is for the sole use of the intended recipient(s) and may
contain confidential and privileged information.  Any unauthorized review,
use, disclosure or distribution is prohibited.  If you are not the intended
recipient, please contact the sender by reply E-mail, and destroy all copies
of the original message.



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

Reply via email to