Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 20, 2007, 08:53 AM   #1
Poeben
macrumors 6502
 
Join Date: Jul 2004
AppleScript: mount volume - help

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
__________________
†Actual post may vary from original thought.
Poeben is offline   0 Reply With Quote
Old Jun 21, 2007, 10:13 AM   #2
jeremy.king
macrumors 603
 
jeremy.king's Avatar
 
Join Date: Jul 2002
Location: Fox Lake, IL
Script looks fine. You sure you haven't unchecked the Connected Servers in your Finder preferences?

You can also browse to /Volumes to see if the drive actually was mounted.

While I use the Applescript route as well, this guy took a different approach.

http://julipedia.blogspot.com/2007/0...s-startup.html
jeremy.king is offline   0 Reply With Quote
Old Jun 21, 2007, 03:13 PM   #3
Poeben
Thread Starter
macrumors 6502
 
Join Date: Jul 2004
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.
__________________
†Actual post may vary from original thought.
Poeben is offline   0 Reply With Quote
Old Jun 24, 2008, 05:55 AM   #4
two123
macrumors newbie
 
Join Date: Jun 2008
http://hornware.com/sharepoints/
two123 is offline   0 Reply With Quote
Old Nov 1, 2012, 08:21 PM   #5
famousfilm
macrumors newbie
 
Join Date: Nov 2012
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 OllyW; Nov 2, 2012 at 02:24 AM. Reason: Please use code tags
famousfilm is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Mount a Directory as a Volume? AmestrisXServe Mac OS X Server, Xserve, and Networking 0 Feb 8, 2014 02:17 AM
Incremental volume adjustments with AppleScript? wrignj08 Mac Programming 5 Jul 28, 2013 05:41 AM
Mount ssh volume with Applescript MacPC Windows, Linux & Others on the Mac 2 Feb 18, 2013 05:36 AM
applescript help : Auto mount sparsebundle image at login MyRomeo OS X 10.8 Mountain Lion 1 Nov 13, 2012 09:25 AM
Applescript to unmount/mount drive on identifier other than volume name? mixvio OS X 10.8 Mountain Lion 0 Sep 6, 2012 04:20 AM

Forum Jump

All times are GMT -5. The time now is 09:19 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC