Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Poeben

macrumors 6502
Original poster
Jul 29, 2004
346
0
In trying to figure out a way to have network volumes auto-mount at startup without ending up with a desktop full of finder windows I came across an Applescipt. I made some changes (addition of a few delays and '2nd attempts' as it did not work consistently,) and all seems to work ok.

Now the problem is, when I connect to the machine over the network (afp) neither the root volume nor any of the network shares show up. Firewire drives still show up fine, however. I have determined it to be somehow releated to the script but I can't see how... Any ideas? Can anyone suggest a better way to auto-mount at startup (short of using NetInfo on OSX server)?

Here's the code:

Code:
tell application "Finder"
	delay 0.3
	try
		mount volume "afp://sumdumuser:sameolpw@MAC-SERVER.local/FTP"
		
	on error
		delay 1
		try
			mount volume "afp://sumdumuser:sameolpw@MAC-SERVER.local/FTP"
		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 {"Okay"} default button 1
		end try
	end try
	
	delay 0.3
	
	try
		mount volume "afp://sumdumuser:sameolpw@MAC-SERVER.local/AnotherVolume"
		
	on error
		delay 1
		try
			mount volume "afp://sumdumuser:sameolpw@MAC-SERVER.local/AnotherVolume"
			
			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 {"Okay"} default button 1
		end try
	end try
	
end tell
 

Poeben

macrumors 6502
Original poster
Jul 29, 2004
346
0
Thanks for the link. I had tried to find a way to do it with a shell script using the 'mount' command, but the syntax was a bit intimidating. I'll keep working towards that angle...

Also, just to clarify, when I connect to another mac I am not even given a choice to mount the system drive (i.e. no volumes show up in the list of volumes to mount, nor does the home folder.) If any firewire drives are connected, however, they will show up.
 

famousfilm

macrumors newbie
Nov 1, 2012
1
0
Hope this helps...

I have been searching FOREVER to find a script that would:
1: Mount a network drive (which might still be booting when the computer is turned on)
2: Not give annoying messages.

If others out there on the interwebs are searching for such an applescript, here is what I came up with. So far, it seems to be working. You'll need to change the ip address of the shared drive and the user/pass, as well as customize anything you want (how long before it retries, etc).

It basically:
1: Tests to see if a mount point exists. If not, it creates one.
2: Runs every 30 seconds up to 9 times (~5 mins) and tries to mount the network drive.
3: After 9 tries, it exits.

** I am not a programmer, so this syntax may not be "clean", but it works. **


Code:
global x
set x to 0

set mounted to do shell script "test -d /Volumes/share && echo yes || echo no"
if mounted = "no" then
	do shell script "mkdir /Volumes/share"
else
	do shell script "echo 'mounted'"
end if

repeat until x > 8 or (list disks) contains "share"
	tell application "Finder"
		try
			do shell script "mount_afp -dv afp://[user]:[password]@192.168.1.1/share /Volumes/share"
		on error
			set x to x + 1
			delay 30
		end try
	end tell
end repeat
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.