Need Help On a Script

Hi,

We have a box where we get file every month on a particular folder. The files cud come any time and any day to the folder and the number of files is also not constant.

I have to write a script whjic will send mail to us on receving the files.
it mean any time one file comes, it will send an alert instantly with the name fo the file.

I belive i am explanation is understandable.

Expecting Help.

What OS is on the box getting the new files?

It is a Unix Solaris Box

When you say instantly, what delay is acceptable?

while :
do
    # choose on of both below
    LS1="$(ls -l | head -1 | cut -d' ' -f2)" # Total files
    # LS1=$(stat $PWD -c %Y) # last modified
    if [ $LS1 -gt $LS2 ]
    then
    # Put here the Mail procedure
    fi
    LS2=$LS1
    sleep 5 # To check every 5 seconds (could be sleep 1m for 1 minute...)
done

instantly mean, lets say within 5min it sud alert by sending the mail...........

So you can use the script above and

  1. choose one of both ways you want to check the dir contents.
  2. add the appropriate code to send mail (depending on mailing utilities you dispose).
  3. set the sleep time to i.e. 5 mins. ("sleep 5m").