Re: Shell Script Failure
Re: Shell Script Failure
- Subject: Re: Shell Script Failure
- From: Tim Goeree <email@hidden>
- Date: Tue, 29 Nov 2005 21:32:40 +0100
- Thread-topic: Shell Script Failure
Title: Re: Shell Script Failure
> I just stumbled across AppleScript's "do shell script"
> functionality. Very handy. However, whenever I execute a certain
> command within the shell script, I get an error. The command is
> "diskutil unmount [identifier]" to unmount a partition. It works
> fine on the command line or in a perl script, but when I call the
> script from AppleScript an odd thing happens: AppleScript kind of
> hangs for a while, then diskutil throws the error "Volume failed to
> unmount". Simultaneously the volume DOES unmount! So when I add
> AppleScript to the equation, diskutil does weird stuff.
It's not really AppleScript per se that's causing the problem, it's
the fact that "do shell script" runs the command synchronously --
that is, it waits until the command exits -- and unmounting a disk is
inherently asynchronous. (There's some horrible technical reason why
which I don't recall at the moment.) The simplest solution is to
make the command execute asynchronously, as described in <http://
developer.apple.com/technotes/tn2002/tn2065.html>:
do shell script "diskutil unmount blah &> /dev/null &"
This does come with a caveat: the disk probably won't be unmounted by
the time the next line executes. However, if you don't care about
that, then it works great.
You could also use “umount –f theVolume” I use it and it works great. Just use “diskutil –r” afterwards and everything is fine.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden