Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Automount AFP shares using Applescript Network
I was unable to get one machine to automount due to an error code -36 when I placed aliases within Startup Items. After spending some time on the issue, I realized that the issue was related to OS X not initializing AFP before the StartupItems. I couldn't find an easy workaround for that, so I implemented an AppleScript that would do the trick for me.

You need to connect to the shares as you normally would, either by browsing to the server, or by using the "Connect To Server..." option on the "Go" menu within Finder. After all the shares have been connected, highlight all of them and make aliases of all of them. If you're lazy like me, rename them to something simple (i.e. '1', '2', etc.). To hide this implementation from the user, hide the aliases in a directory somewhere the user can't see them (I created a "server-automnt" folder on the hard drive). Write the following script (with changes for your system) in AppleScript:
delay 10
tell application "Finder" 
    open file "Macintosh HD:server-automnt:1"
    open file "Macintosh HD:server-automnt:2"
end tell
Save the script as an application, and turn off the startup screen option. Go to System Preferences. Goto Accounts. Goto Startup Items. Drag the AppleScript into the list. Reboot.

Now, you should have automounting AFP shares despite the error code.
    •    
  • Currently 2.25 / 5
  You rated: 4 / 5 (4 votes cast)
 
[52,120 views]  

Automount AFP shares using Applescript | 9 comments | Create New Account
Click here to return to the 'Automount AFP shares using Applescript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automount AFP shares using Applescript
Authored by: andyinindy on Feb 18, '05 12:35:52PM
I use this Applescipt as a Login Item:

set sfiles to "afp://username:password@peter.butler.edu/student_files"
tell application "Finder"
	activate
	mount volume sfiles
end tell
No errors, works like a charm. What is this -36 error of which you speak?

[ Reply to This | # ]
Automount AFP shares using Applescript
Authored by: knujon on Feb 18, '05 01:32:24PM

Great hint; thanks. Do either of you, or does anyone else know how to do the opposite, to un-mount a network share?

Thanks in advance...



[ Reply to This | # ]
Automount AFP shares using Applescript
Authored by: allanmarcus on Feb 18, '05 02:48:14PM

sudo umount /Volumes/sharename

where sharename is the mounted volume. Do an

ls -l /Volumes

to see what's mounted.



[ Reply to This | # ]
Automount AFP shares without Applescript
Authored by: yan.nl on Feb 18, '05 08:41:49PM

Maybe i'm just a lucky bastard not needing al this. I dsilike using passwords etc. in scripts.
My most simple solution to mount a AFP share is just simply 'add' the (mounted) volume to the login items in teh account preference pane ...

---
Ukraine Spy



[ Reply to This | # ]
Automount AFP shares using Applescript
Authored by: allanmarcus on Feb 18, '05 02:53:47PM

AFP is initialized before the login screen is displayed, so something else is going on with your machine.

You should not need an AppleScript to automount an AFP volume. here's what you do:

1) Mount the AFP volume with the finder
2) goto ~/Library/Recent Servers
You should see a file with the same name as the server you just mounted.
3) Drag this file into the login items in the Accounts system pref.

You will be prompted for a password after the finder loads, and if you authenticate, the volume will be mounted.

To mount a specific volume, in step one enter:

afp://server-name.com/volume-name



[ Reply to This | # ]
Automount AFP shares using Applescript
Authored by: billoday on Feb 18, '05 05:08:26PM

That was what I had done, unfortunately that stopped on one machine shortly after we got it working. The other nine machines had no problems with that method. This is to force the automount, nothing more.



[ Reply to This | # ]
Automount AFP shares using Applescript
Authored by: DanFrakes on Feb 19, '05 05:17:25AM

You can do this easily without having to resort to AppleScript. Simply type the full URL of the share in any text field (like a TextEdit document):

afp://username:password@IPaddress/sharename

Highlight the URL and then drag it to the Finder. This will create an Internet Location file. Drag that file into Startup Items and the share will be mounted the next time you login.



[ Reply to This | # ]
Automount AFP shares using Applescript
Authored by: ntloser on Sep 11, '07 03:33:26PM

I had no problem mounting shares using a similar apple scripit

mount volume "smb://whatever/whatever"

Originally I had the script mounting 4 volumes without specifying any "credentials"

I changed the script so that it mounted a 5th volume and used supplied a un and pw.

like this;
mount volume smb://username:password@whatever/whatever

I then got error 36. I could run the script fine. Finally I added a 2 second delay and it worked again.

I am new to OSX and just got my first mac last week. I had used the hacked version on a PC and even through some of the hardware wasn't supported I realized I liked the OS.



[ Reply to This | # ]
Automount AFP shares using Applescript
Authored by: hohabadu on Sep 12, '07 07:40:07AM

is it an firewire-device?

error 36 appears to be an I/O-Error

H =:o) L G I



[ Reply to This | # ]