Mount Volume Issue in 10.3


I am trying to write a script that monitors a number of mounted network volumes on my mac os x 10.3.9 G5 Xserve.

The script is controlled by the cron daemon and checks that the volumes are mounted every 5 minutes. If one of the volumes is found to be not mounted, the script will attempt to re-mount it.

Now…really the only reason that a volume would become dismounted would be if the host server went down/offline. If this happens, it may be a little while before that volume is available to mount. I am try to modify the script to handle that situation…however it appears that the mount volume command has a mind of its own.

I put my mount volume in a try statment and also tried to trap any errors…however every time I run the script against a server that is down…i get the same error from the mount volume command itself…not my error trap. I get

Connection failed

No Response from the Server. Please try again

The only option is to hit the OK button…then it does it a second time before moving on and then catching any errors. It appears the mount volume command has its own error trap built in that you cannot work around. I want this script to be automatic…but it appears to require user intervention if the server is down.

Is there a way around this…am I missing something…os is the mount volume just written poorly???

FYI…here is the code

with timeout of 5 seconds
mount volume “afp://servername/volume” as user name “USER” with password “PASSWORD”
on error errmesg number errn
display dialog “I got an error”
end try

I see the Connection failed message above twice…and I have to manually hit OK twice…before I would see my dialog box that says"I got an error". If anybody knows what I am talking about and has an answer…please help!!!

Try something like:

tell application "Finder"
	set mounted_Disks to list disks
	--display dialog result as string
	set mounted_Disks to every disk whose (ejectable is true)
end tell
if mounted_Disks does not contain "INGEST" then
	mount volume "cifs://user@SERVER/SERV_VOL" with password " "
end if

This simply will mount the Volumes or Disks if they are not in the list.

Thanks Brandon…but I am still having the same issue. The problem is with the Mount Volume command itself it seems. How can I supress, ignore, or accept the connection error thrown by the mount volume command itself within my applescript???

You code worked just fine…but as soon as I turn off the server I am trying to mount…i get the same error and it requires manual intervention. I am lost here…is there any way I can trap that error or prevent it from being thrown in the first place. With this script…I need to be able to account for the fact that the server i am trying to reach might not be up.

thank you for your help.

I’m not sure you can really blame ‘mount volume’. I have had a similar problem. We have a UNIX server using Helios to create our Mac volumes. To make a long story short, a license issue was producing a warning message that the Helios license was going to expire in 3 months. I couldn’t find a way around the problem until I abandoned ‘mount volume’ completely.

I am mounting volumes with ‘do shell script’. First I make a directory in my ‘/Volumes’ directory to act as the mount point and then mount the volume to the mount point. You’ll probably need to read some man pages in the terminal to get up to speed but this has turned out to be much more robust and reliable and I don’t get any of the dialog boxes that I did with ‘mount volume’.

set script_result to ""
set disk_list to list disks
if disk_list does not contain "Volume Name" then
		set dir_count to do shell script "ls /Volumes | grep -cx 'Volume Name'" -- This will count the directories with 'Volume Name'
	on error errMess number errNum
		set dir_count to errMess
	end try
	if dir_count = "0" then
		do shell script "mkdir '/Volumes/Rip & Ship'"  --Create the directory to use as a mount point
	end if
		do shell script "mount -t afp 'afp://user id:password@IP address/Volume Name' '/Volumes/Volume Name' 2> ./scripterror.txt"
	on error errMess number errNum
	(* If something goes wrong, get rid of the directory you created *)
		do shell script "rmdir '/Volumes/Volume Name'"
	end try
end if

WARNING This does not deal with the possiblity of different volumes with the same name.

I do somthing similar with this - the volume is always available so I’m not sure if it will fix your error problem. Note that with this one I just leave it running as it’s part of a bigger script that does other stuff - therefore I don’t use Cron with it…

on idle
		set mounteddisks to list disks
	if mounteddisks does not contain "Volume Name" then
		mount volume "afp:// Name" as user name "username" with password "password"
			end if
	return 120 -- idle time, in seconds, between executions 
end idle