Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Auto-notify of changes in Drop Box contents Desktop
Have you ever wanted to be informed when someone puts something into your public drop-box? OS 9 used to allow you to attach apple scripts to a folder, and have them run when the contents changed. I don't think you can do that any more! So, here's a script which will email you when your drop-box contents changes.

Read the rest of the article for the script...

Firstly, you need to set the permissions on / so that sendmail will run. Do this by typing the following in the Terminal:
chmod g-w /
chmod g-w /etc/
chmod g-w /etc/mail/
Otherwise, sendmail complains about the permissions of the directory structures - it's a safety feature.

Ok, so now for the script. Basically we want to check the contents of the dropbox on a regular basis, so we have to record the 'last-known contents'. Type the following using your favorite editor, and put it somewhere safe (I use ~/bin, but see the note on security later)
#! /bin/sh

ls ~/Public/Drop\ Box >~/Documents/.NewDropBoxList
diff ~/Documents/.DropBoxList ~/Documents/.NewDropBoxList >/tmp/$$tmp1
if test $? -eq 1
then less /tmp/$$tmp1 | mail -s "`hostname` new dropbox items" username
fi
mv ~/Documents/.NewDropBoxList ~/Documents/.DropBoxList
Obviously, you will want to replace "username" with your own username or email. If you use a username ie. fred, then make sure you're fetching UNIX mail, or the whole thing won't work. See here for info on how to set up mail.app to recieve local UNIX mail.

Now all you have to do is set up a dummy, empty contents list, and install the cron job. The empty list is created with the following line
echo >~/.DropBoxList
and the cron job can be installed to run as often as you like. I'd suggest every 10-20 minutes, which is achieved by using */20 in the minutes column of crontab. A quick note on security: It's not a good idea to allow group-write access to files you run as a cron job, because otherwise someone can overwrite your script, and hey-presto they can run any command as you. For that reason, make sure you do the following on both the script and it's containing directory:

chmod go-w ~/bin/CheckDropBox
chmod go-w ~/bin
Enjoy ;)

[Editor's note: I have not tried this myself...]
    •    
  • Currently 2.50 / 5
  You rated: 3 / 5 (4 votes cast)
 
[7,533 views]  

Auto-notify of changes in Drop Box contents | 5 comments | Create New Account
Click here to return to the 'Auto-notify of changes in Drop Box contents' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Script Error
Authored by: The Gimp on Feb 01, '02 01:46:46AM

The second script has bad syntax. On line 7, the Editor reports an error. I tried my puny bit of AppleScript knowledge, but it still has me stumped. I do like the fact that classic is dead... I kept tapping my heals together and saying "I wish classic was dead (so on, and so forth)" but that didn't work. I named first script "Classic Raid" because it kills Classic on contact.

Nice work "Anonomous"!



[ Reply to This | # ]
Shell script...
Authored by: robg on Feb 01, '02 08:56:29AM

The above is a shell script, not an AppleScript. It needs to be created in a raw text editor and then made into an executable file (chmod 755 filename).

-rob.



[ Reply to This | # ]
pow!
Authored by: mervTormel on Feb 02, '02 03:01:58AM

i think this represents the real beauty and power of unix. here's something that some poor team of developers slaved over for nine months to implement in OS9, that can be thoroughly replicated by a four line shell script in unix.

with a little knowledge, ingenuity and cleverness, the tools you can create in unix-land are infinitely beautiful and mind-boggingly simple.

it's a bizarre system, at first. but after you turn the corner, Oz! you realize what a good philosophy the designers had in mind.

but, don't get me started talking about the inconsistencies in the man pages! #@%$^&*

Keep diggin'



[ Reply to This | # ]
Auto-notify of changes in Drop Box contents
Authored by: mprewitt on Jun 16, '03 10:59:28AM

Here is, in my opinion, a simpler solution done via AppleScript.

I wrote the following script to alert me of any incoming items. It does this by speaking the number of items in your drop box (but only if there are any), and if there are items it will also open the Drop Box folder automatically. Obviously what it does when it finds items in your Drop Box can be changed to suit your preferences. I saved this as an application and used cron to schedule this to run once each afternoon.

You will need to change "YOUR-USER-NAME" to your actual user name, and "VOLUME" to the drive your users folder is on.

[code]
tell application "Finder"
set myCount to (count every file of folder "Users:YOUR-USER-NAME:Public:Drop Box" of disk "VOLUME")
set myDialog to "You have " & myCount & " items in your drop box!"
try
if (myCount > 0) then
if (myCount = 1) then set myDialog to "You have one item in your drop box!"
say myDialog
open folder "Users:YOUR-USER-NAME:Public:Drop Box" of disk "VOLUME"
end if
end try
end tell
[/code]



[ Reply to This | # ]
Auto-notify of changes in Drop Box contents
Authored by: sjk on Jun 16, '03 09:04:25PM

Any reason not to use Folder Actions for this sort of thing?



[ Reply to This | # ]