Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   AppleScript issue (http://www.mac-forums.com/forums/os-x-development-darwin/283479-applescript-issue.html)

huntson 09-02-2012 02:44 PM

AppleScript issue
 
I am fairly new to AppleScript and need some help with the following line:


do shell script "diskutil unmount \"Volumes/" & bob


Bob is the variable of the name of the volume I want to pass to the shell script. No matter how I do it - I cannot get the end of the line correct in terms of quotes.* I get the following error in its current state

sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file

Mark FX 09-05-2012 01:47 PM

Show the code for how you have set the bob variable, as I'm guessing
that is where the problem is.

Regards Mark

vansmith 09-05-2012 02:02 PM

You need to add a quotation mark at the end.

Pretend bob has a value of external_disc. Let's construct the command now, replacing bob with the value:
Code:

do shell script "diskutil unmount \"Volumes/external_disc"
See the problem? You've started putting quotation marks around the volume name but didn't put a closing one. You've also forgotten to put a forward slash before Volumes.

Mark FX 09-05-2012 02:25 PM

As vansmith has eluded too, you have three quotation marks, and also
a backslash before Volumes, that should be a forward slash.

Try something like this.

Code:

set myVolume to "bob"
do shell script "diskutil unmount /Volumes/" & myVolume

Regards Mark

vansmith 09-05-2012 02:42 PM

The backslash before the second quotation mark may be there on purpose though if he's trying to escape it so as to put the volume path in quotation marks (perhaps the volume name has a space?).

Mark FX 09-05-2012 02:52 PM

That's possible, but he still needs to have forward slash in front of Volumes, to indicate
its off of the root path.
Also I suspect he is building his bob variable as a alias HFS type path, instead of a POSIX
style path, but we'll see.

Mark


All times are GMT -4. The time now is 03:31 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.