Obvious and undocumented?

I try to “unmount” a network volume using the full path. I guess it is all about constructing the right global for the disk in question, but I am a new to this. Searched forums, faq and internet extensively before posting.

Trying all kinds of bad grammar like

unmount “afp://XXX.XX.X.XX/TheVolumeToUnmount”

set theDisk to “afp://XXX.XX.X.XX/TheVolumeToUnmount”
eject theDisk

eject “afp://XXX.XX.X.XX/TheVolumeToUnmount”

set theDisk to the disk of “afp://XXX.XX.X.XX/TheVolumeToUnmount”
eject theDisk

Ouch, that was bad scripting!

A pure eject “Diskname” won’t work since there are several disks with same name mounted (stupid, yes, but out of my control)

Shell scripting won’t work (?), since the users are not administrators.

Thankful for any push in the right direction.

hey bme,
i’m not sure, which syntax to use exactly, since i don’t have a network volume to experiment on, but i can think of a couple of problems with what you’ve tried:

  1. the eject command should reside within a finder tell block as in:

tell application "finder"
      eject disk thedisk
end tell
--etc.

  1. applescript commands do not accept posix passes (with the “/” character), you cab use “posix file” command to convert it to AS pathname,
set thedisk to posix file "afp://XXX.XX.X.XX/TheVolumeToUnmount"

but i’m not sure if that’ll work on remote volumes.

maybe the best way is to use applescript to send a unix shell command, as in


do shell script "hdiutil eject -quiet " & "thedisk" -- the original posix path

you can look at the “do shell script” command in the scripting addition dictionary, and at “hdutil” man pages for more details.

First of all I apologize for the idiotic naming of this topic, secondly I am glad you found it anyway and read this far.

Basically, what I need is an “eject” or “unmount” or whatever command that is path-specific and user executable, i.e. is not referring solely to the disk name (since theoretically several volumes with identical names might be mounted). This issue has bearing on any instant when a full path is needed, hasn’t it?.
noiroi writes:

Well, the tell block was there. Sorry, I was trying to keep the post short and omitted the tell block from my original post.
noiroi writes:

That might be something… However, when I tried it exactly like that:


tell application "Finder"
	mount volume "afp://XXX.XX.X.XX/TheVolumeToUnmount" --works fine
	set theDisk to posix file "afp://XXX.XX.X.XX/TheVolumeToUnmount"
	eject theDisk
end tell

it automatically compiles to:


tell application "Finder"
	mount volume "afp://XXX.XX.X.XX/TheVolumeToUnmount" --works fine
	set theDisk to file "StartUpDisk:TheVolumeToUnmount"
	eject theDisk
end tell

which returns error -1728. Displayed in:


tell application "Finder"
try
	mount volume "afp://XXX.XX.X.XX/TheVolumeToUnmount" --works fine
	set theDisk to file "StartUpDisk:TheVolumeToUnmount"
	eject theDisk
	on error ErrorText number ErrorNumber
		HandleError(ErrorText, ErrorNumber) of me
	end try
end tell
on HandleError(ErrorText, ErrorNumber)
	display dialog ErrorText & ErrorNumber
	end HandleError

noiroi writes:

Is this really a viable option? As I wrote in the first post I cannot prompt for administrator privileges. Ordinary users will have to be able to run the script.