Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

danb77

macrumors 6502
Original poster
Sep 4, 2007
442
3
Hi,

I am trying to write a .sleep script to employ with the handy SleepWatcher utility to unmount my USB disks and network disks when I send my MacBook to sleep.

My current script is

#!/bin/sh
osascript -l AppleScript -e 'tell Application "Finder" to eject every disk whose ejectable is true or not local volume is true'


The problem with this is that it does not verify that the unmount has been successful, so sometimes the computer shuts down with the drives still mounted.

Does anyone have an idea how I can change the script to:

Wait until the mount has been successful before finishing (and allowing SleepWatcher to shut the system down)

If this does not occur within n seconds display an error message.

Thanks in advice,

Dan (the applescript newbie!)
 

danb77

macrumors 6502
Original poster
Sep 4, 2007
442
3
OK, so maybe this wasn't the best place to post this question. Can anyone recommend a good Applescript forum?
 

MongoTheGeek

macrumors 68040
Hi,

I am trying to write a .sleep script to employ with the handy SleepWatcher utility to unmount my USB disks and network disks when I send my MacBook to sleep.

My current script is

#!/bin/sh
osascript -l AppleScript -e 'tell Application "Finder" to eject every disk whose ejectable is true or not local volume is true'


The problem with this is that it does not verify that the unmount has been successful, so sometimes the computer shuts down with the drives still mounted.

Does anyone have an idea how I can change the script to:

Wait until the mount has been successful before finishing (and allowing SleepWatcher to shut the system down)

If this does not occur within n seconds display an error message.

Thanks in advice,

Dan (the applescript newbie!)

try this.

#!/bin/sh
umount -f /volumes/*

It will fail on the system disk unless you are running as root but will unmount everything else.

As for a place to ask scripting questions there is the MACSCPT listserv run out of Dartmouth. Volume has dropped off tremendously but there are a lot of people there with a lot of knowledge in different scripting languages.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.