How to automatically mount a share in OSX

At some point, you might need to automatically mount a share in OSX.  I wanted to automatically mount my Time Machine share that I made in Linux (See this article)

Its quite simple to do.  Just open up AppleScript from Utilities and enter the following information:

tell application “Finder”

mount volumeprotocol://username:password@server ip or name/sharename

end tell

You want to be editing all the bits in green.  The protocol can be things such as afp or smb.  If you want to automatically mount the Time Machine share you made in one of my other articles, then use afp.

This is what my script looks like

tell application “Finder”

mount volume “afp://greg:password1234@192.168.2.101/Time Machine”

end tell

 Once you have wrote the script, click compile and then run it.  Hopefully you should see your share get mounted.  You can then save this, however make sure you save it as an Application from the drop down list.

Then, just go to System Preferences -> Accounts.  Under your account, click the Login Items tab and add the application you just made into there.