AppleScript issue

Joined
Sep 2, 2012
Messages
1
Reaction score
0
Points
1
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
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Show the code for how you have set the bob variable, as I'm guessing
that is where the problem is.

Regards Mark
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
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.
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
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

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
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?).
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
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
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top