Launch shell script when volume is mounted
Hi all. I'm new to this list, and have a question about a task I'm trying to accomplish that seems to me pretty straightforward. I want to run a shell script whenever a volume is mounted – and the shell script needs to somehow know what the name of the volume is that has just been mounted. I know it can be done (HardwareGrowler does it), but I just haven't found out how yet. Initially, I thought I could do it using Peter Borg's lingon app (http://www.peterborgapps.com/lingon/); this *almost* did the job, but I have checked with the developer, and he told me that although his app can detect when a volume is mounted, it can't pass the name of the mounted volume in to the shell script that is run. He then directed me to this list. So: any help would be most appreciated! kind regards, Matt
On 2011 Apr 18, at 12:32, Matt Calthrop wrote:
I want to run a shell script whenever a volume is mounted – and the shell script needs to somehow know what the name of the volume is that has just been mounted.
I know it can be done (HardwareGrowler does it), but I just haven't found out how yet.
Read: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPa... You will find: StartOnMount <boolean> This optional key causes the job to be started every time a filesystem is mounted. And if that doesn't work for some reason, maybe try and "watch" /Volumes using this: WatchPaths <array of strings> This optional key causes the job to be started if any one of the listed paths are modified.
Thanks Jerry. However: the key thing here is that I want to know the name of the volume that has just been mounted - that information is not passed in to the script that is executed. I've tried both the StartOnMount and WatchPaths methods - and both behave the same way: no name of the the volume just mounted. Have found another (hacky) way of doing the job; will reply in separate email. Matt On 19 April 2011 20:39, Jerry Krinock <jerry@ieee.org> wrote:
On 2011 Apr 18, at 12:32, Matt Calthrop wrote:
I want to run a shell script whenever a volume is mounted – and the shell script needs to somehow know what the name of the volume is that has just been mounted.
I know it can be done (HardwareGrowler does it), but I just haven't found out how yet.
Read:
http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPa...
You will find:
StartOnMount <boolean> This optional key causes the job to be started every time a filesystem is mounted.
And if that doesn't work for some reason, maybe try and "watch" /Volumes using this:
WatchPaths <array of strings> This optional key causes the job to be started if any one of the listed paths are modified.
participants (2)
-
Jerry Krinock
-
Matt Calthrop