10.12 and volumes killed my script

Hi All…

I created a script which would essentially name, mount drives and create a folder with sub folders all correctly named. But since Apple changed the permissions on the /Volumes I can mount the drives but it doesn’t see the volumes as an alias to choose the correct folder… I have attached the part of the script that no longer works… If any one knows how to to solve or help with this id appreciate it…

Thanks Rob

-- Try to connect to live projects Volume
		try
			mount volume "afp://192.168.53.200/LIVE PROJECTS/"
			
		on error
			display dialog "There was an error mounting the Volume." & return & return & "The server may be unavailable at this time." & return & return & ¬
				"Please inform the Network Administrator if the problem continues." buttons {"Quit"}
			error number -128
			
		end try
		try
			-- Ask user for folder destination
			choose folder with prompt "Choose the client folder for STUDIO or create a new client folder." default location "/Volumes/LIVE PROJECTS"
			
			set LiveProjects_AreaClient to result
			
			
			-- Ask user for folder destination
			choose folder with prompt "Choose the client folder for CLIENT SERVICES or create a new client folder with the _CS suffix." default location "/Volumes/LIVE PROJECTS/*Client_Services_Area"
			
			set CS_Area_ClientFolder to result
			
		on error
			error number -128
			
		end try

What would you get if you run :

-- Try to connect to live projects Volume
try
	mount volume "afp://192.168.53.200/LIVE PROJECTS/"
	
on error
	display dialog "There was an error mounting the Volume." & return & return & "The server may be unavailable at this time." & return & return & ¬
		"Please inform the Network Administrator if the problem continues." buttons {"Quit"}
	error number -128
	
end try

tell application "System Events"
	exists folder "/Volumes/LIVE PROJECTS"
	log result
	exists folder "/Volumes/LIVE PROJECTS/*Client_Services_Area"
	log result
end tell

My understanding is that you will get :
true for exists folder “/Volumes/LIVE PROJECTS”
false for exists folder “/Volumes/LIVE PROJECTS/*Client_Services_Area”

Here I get the error message :
error “Impossible de convertir "Volumes/Macintosh HD/Developers" en type alias.” number -1700 from “Volumes/Macintosh HD/Developers” to alias
when I try to execute:

choose folder default location "Volumes/Macintosh HD/Developers"

for the simple reason that there is no folder named Developers (with a plural s) on the disk named Macintosh HD (which is not my boot disk).

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 4 juillet 2017 16:58:00

Hi Yvan

Thanks for the reply…
That’s correct it does return a false but unfortunately I cant really see how this help me solve the problem.

It all worked nicely before 10.12.
So I’m unsure how to get round the mounting of the volume and then allowing the user to choose the destinations they require via finder. When they choose the destinations (the variables) and they in return then become the destinations of the folders later in the script…

Now when its runs it shows the LIVE PROJECTS with the no entry sign as the /Volumes is inaccessible by the user. and now keeps replicating itself every time… so LIVE PROJECTS-1 and -2 so on… You can scroll down to the mounted volume in the finder window but i cant expect the user to keep doing this… They will have of folders to scroll through…

Thanks Rob

It’s simple : if it returns false it’s because the folder “/Volumes/LIVE PROJECTS/*Client_Services_Area” doesn’t exist.
It explain why you get the error message
error “Impossible de convertir "/Volumes/LIVE PROJECTS/*Client_Services_Area" en type alias.” number -1700 from “/Volumes/LIVE PROJECTS/*Client_Services_Area” to alias

I’m wondering if you are guessing that the asterisk available in your POSIX path is a wildcard.
If it’s that, you are guessing wrongly : choose folder doesn’t accept wildcards.

I apologizes but I never used networks so I can’t run the code trying to understand the meaning of :

If I run the code :

choose folder default location "Volumes/Macintosh HD/Developer"

all behave flawlessly and I can create a new folder.
The script returns :
alias “Macintosh HD:Developer:beurk:”

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 4 juillet 2017 18:12:33

Hi Yvan…

Sorry i think we may have wires crossed here slightly my issue isn’t that it doesn’t mount or that i get an error, its that Finder cant then see the volume thats mounted, due to the change in Sierras handling of volumes nothing else.

Please ignore the Client services folder thats just a sub folder of LIVE PROJECTS… its not a wild card just part of the name of the sub folder…

What i now get when running the script is a blank finder window with a LIVE PROJECTS with a no entry sign for the user to choose a folder from. I’m not sure how to post an image on here…

Thanks Rob

You may send a screenshot to my mailbox. My address is available below - with extraneous spaces.
k o e n i g . y v a n @ s f r . f r

I repeat that here I have no problem - running 10.12.5 - to choose a folder and to create one with the instruction :

choose folder default location "Volumes/Macintosh HD/Developer"

so I don’t understand why it doesn’t work for you.

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mardi 4 juillet 2017 19:12:58

@Yvan: When volumes are mounted it requires an existing path. So you create an empty directory (also known as nodes) and mount the volume there. When you unmount you remove this folder when done (this can be done automatically for you in higher level dan BSD).

The difference between Sierra and earlier OS versions is that the privileges on “/Volumes” is 777 on earlier systems which means every user can read and write in this folder. To improve security the owner root of “/Volumes” can read and write which means other users cannot create nodes to mount volumes.

@Frosty1973: You return an error in your try and you will stop the script. To get around the mounting (making it work) by using the lower level mount_afp command line util. What I did was creating a folder “mnt” in my user home folder. Then in that folder I created an empty folder with the same name as the volume I want to mount. When I mount the volume there the volume will be visible in the Finder like any other volume but also be visible in the ~/mnt/volume

[format]mkdir $HOME/mnt/volume
mount_afp afp://username:password@server/volume $HOME/mnt/volume[/format]

The shell script above can be invoked using an do shell script

Hello DJ

I’m not sure that your explanations match the problem.

I received a screenshot from the asker.
It display the choose folder dialog.
The volume “LIVE PROJECTS” is displayed but it has a red “write disabled” badge.
I may be wrong but my understanding is that it’s not Volumes which isn’t write enabled but only the mounted volume.

Yvan KOENIG running Sierra 10.12.5 in French (VALLAURIS, France) mercredi 5 juillet 2017 10:35:29

Hi Yvan and DJ

Thanks for your help…
Yvan what you sent me does work thanks, but as its a local volume it will do, the network will keep replicating itself overtime when you reconnect. Creating an alias of the volume LIVE PROJECTS in /Volumes followed by -1, -2 etc which are not accessible.

DJ Can the shell be used without the users credentials. As the script is generic for all users and the username and password are in their local keychain. So i don’t ideally want to adapt the script to each individual user?

Thanks Rob