Run script if image is mounted

Hello,

I’ve tried really hard to find a solution but wasn’t lucky. So here is my problem:

I want to execute a sh script (or applescript) each time a volume (e.g image file) is mounted.

Example: I mount the image “test.img” → and get the volume “testImage”
A script (or action) catches this event automatically and starts my script /dev/runscript.sh

Now I don’t know how to monitor the volumes list all the time without having an applescript running in the backround checking the volumes list. Does OS X (Leopard) supply a service for this?

I found a little application to do exactly what I want at http://azarhi.com/Projects/DSW/index.php but I don’t want to install it on every computer that uses my script.

Thank you so much for your help!

Geps

Hi,

but you have to install a functionality to watch the folder /Volumes.
The smartest way is a launchd agent which can trigger directly an AppleScript or shell script

Take a look at this article


http://macscripter.net/viewtopic.php?id=24748

Hi,

thanks Stefan, this is EXACTLY what I was looking for!

Best regards

Geps