• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Shell Script Failure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shell Script Failure


  • Subject: Re: Shell Script Failure
  • From: Christopher Nebel <email@hidden>
  • Date: Tue, 29 Nov 2005 11:14:52 -0800

On Nov 29, 2005, at 10:48 AM, Jennifer Charrey wrote:

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.


--Chris Nebel AppleScript and Automator Engineering

_______________________________________________
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


References: 
 >Shell Script Failure (From: Jennifer Charrey <email@hidden>)

  • Prev by Date: The Excel 2004 battle continues
  • Next by Date: Re: [OT] Re: Oh lord, here we go again
  • Previous by thread: Shell Script Failure
  • Next by thread: Re: Shell Script Failure
  • Index(es):
    • Date
    • Thread