Mounting volume problems.

I wrote a script a while back that utilizes this format to mount volumes on the desktop:

mount volume "afp://userName:password@155.155.155.155/driveName"

There are only two Mac’s on the network with the other Mac having an external hard drive, the user, and the main hard drive. I have the script set up to check for mounted volumes and make a list, excluding those already mounted, of all volumes that can be mounted. If no volumes are already mounted the first volume usually mounts without any problems. If I used the script and then tried to mount a second volume, sometimes it works with out problems and other times it errors saying that some disk could not be found. Sometimes, even though the disk “could not be found” it mounted anyway.

I don’t know what has happened recently, but the format used above results in a spinning beach ball, Finder freezes, and I have to relaunch the Finder. (The ip address is still correct on the machine to be mounted)

I just used this format

mount volume "afp://hardDrive.local./volumeName" as user name "user" with password "password"

without having the freeze problem, but have the same problem as above with the error. When the error came up I tried connecting through the Network (the hard way :wink: ) and the volume I tried to mount was greyed out, but was not actually mounted on my desktop. So I thought that maybe the desktop needs to be updated after an operation so I included this

tell application "Finder" to update desktop

after mounting the volume I wanted, but this does not seem to help. Is this correct for updating the desktop? Has anyone else had a similar problem? Any ideas would help. Thanks

Full code:

set diskList to list disks
set mountedVols to {} as list
set volList to {"OWC Neptune", "Macintosh HD G51", "admin1", "CromaPro"}
set cnt to count diskList

display dialog "Do you wish to mount or dismount volumes?" buttons {"Mount", "Dismount"} default button "Mount"
set butChoice to button returned of the result as text
if butChoice is "Mount" then
	if cnt is not 6 then
		repeat with i from 1 to 4
			if diskList does not contain item i of volList then
				set mountedVols to mountedVols & item i of volList
			end if
		end repeat
		tell application "Finder"
			choose from list mountedVols with prompt "Choose volume/s to mount."
			set choice to result as text
			if choice is "volume1" then
				mount volume "afp://hardDrive1.local./volume1" as user name "uName" with password "pass"
				tell application "Finder" to update desktop
			else if choice is "volume2" then
				mount volume "afp://hardDrive1.local./volume2" as user name "uName" with password "pass"
				tell application "Finder" to update desktop
			else if choice is "volume3" then
				mount volume "afp://hardDrive1.local./volum3" as user name "uName" with password "pass"
				tell application "Finder" to update desktop
			else if choice is "hardDrive" then
				mount volume "afp://uName:pass@155.155.155.155/hardDrive"
			end if
		end tell
	else
		display dialog "All volumes are currently mounted."
	end if
else
	my dismountVol()
end if

on dismountVol()
	tell application "Finder"
		eject every disk
		tell application "Finder" to update desktop
	end tell
end dismountVol

PreTech

Hi, PreTech.

I’m getting exactly the same thing here. What seems to cure it pretty reliably “ at the moment, at least! “ is to omit the user name and password from subsequent mounts once the first network volume is mounted. Assuming that all the names in volList belong to volumes on the other machine, you could compare that list with the list of volumes yet to be mounted:

set choice to (choose from list mountedVols with prompt "Choose volume to mount.")
if (choice is false) then return
if (mountedVols = volList) then
	mount volume ("afp://uName:pass@155.155.155.155/" & item 1 of choice)
else
	mount volume ("afp://155.155.155.155/" & item 1 of choice)
end if

‘mount volume’ is a StandardAdditions command, so you don’t need to tell the Finder to do it. But I don’t know what’s been causing your “spinning ball” problem. :expressionless:

Thank you Nigel! :smiley: It didn’t even occur to me that using the password and such every time would cause problems. That’s what’s great about this site - more heads are better than one :smiley:

PreTech

the open location command allows for passwords…

open location (“afp://” & username & “:” & psswrd & “@” & ipaddress & “/” & thisDisk)