Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

seeing when a file is written to a dir

Status
Not open for further replies.

pappyinsc

Technical User
Feb 25, 2003
3
US
I will start this out with, I am a terrible script writer. I am an app support person with limited script skills. My question is 2-fold.

1 - what book(s) would someone recommend for beginner and then which book after that to progress quickly.

2 - I need to write a script that notifies me (via text file) when someone writes to a particular directory. I am sure this is possible but I don't even know where to start.

Thank you very much
 
For #2:
tested with Linux, bash:
Code:
#!/bin/sh
while :
do
     mylist=`find $1 -type f -mmin $2`
     if [ ! -z "$mylist" ] ; then 
        for all in $(echo $mylist)
        do
           echo "Filename: $all was changed within the last poll interval"
        done
     fi
mpid=`ps -aux | grep $0 | awk ' { if (NR == 1) ; print $2 ; exit}'`
echo "My Pid is : $mpid"
tm=`expr $2 * 60`
sleep $tm
done

Called like:
scriptname "directorytowatch" "minutes"&

It's a little raw.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top