Re: Unknown token in do shell script
Re: Unknown token in do shell script
- Subject: Re: Unknown token in do shell script
- From: Doug McNutt <email@hidden>
- Date: Thu, 08 Mar 2012 12:13:03 -0700
At 19:23 +0100 3/8/12, Iurista GmbH wrote:
>Hi
>
>I want to unmount a volume.
>When I enter in Terminal % diskutil unmount /Volumes/myDisk\ Leo, that works fine.
>Now I write an applescript: do shell script "diskutil unmount /Volumes/myDisk Leo", that does not work
>But if I write: do shell script "diskutil unmount /Volumes/myDisk\ Leo", Applescript says that the backslash is an unknown token...
>
>What do I wrong?
The problem is that AppleScript uses the backslash character the same way that the shell does.
When Applescript sees the line and appropriately removes the backslash leaving just the space. When passed that way to bash, even though that might not be your chosen shell, the space is treated as a separator of the arguments to the call.
"Quoted Form of" is an Applescript term of art that appropriately quotes stuff. That includes escaping the escape character the right number of times to make it all work.
An easier way is to realize that you're working on a UNIX box and scrupulously avoid using spaces in file names.
Without checking. . .
do shell script quoted form of "diskutil unmount /Volumes/myDisk Leo"
--
Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden