views:

540

answers:

2

I'm using a Mac at work and would like some network shares mounting when i start the computer. Can i use a bash script (or similar) to connect and mount these shares? The shares are from both Windows and Mac servers and we usually connect using IP addresses.

+1  A: 

You could check out mount_smbfs, assuming that your network shares are smbfs/cifs.

mount_smbfs [-N] [-o options] [-d mode] [-f mode] [-h] //[domain;][user[:password]@]server[/share] path

I'm not intimately familiar with the OSX startup process, but it's possible you can create your shell-script as a program/folder in /Library/StartupItems or /System/Library/StartupItems

As mentioned on osxbook.com

/etc/rc finally launches /sbin/SystemStarter to handle startup items from locations such as /System/Library/StartupItems and /Library/StartupItems. A StartupItem is a program, usually a shell script, whose name matches the folder name. The folder contains a property list file containing key-value pairs such as Description, Provides, Requires, OrderPreference, start/stop messages etc. You can run SystemStarter -n -D as root to have the program print debugging and dependency information (without actually running anything).

Kjetil Jorgensen
A: 

You can either do this via a Apple Script which you simple add to the User Startup Items, or do it via Automator and again add to Startup Items (System Prefs -> Users -> Startup Items), If you want to you can also just call a bash script from an AppleScript if you are more familier with Bash, but mounting shares is an easy task anyway. If you maybe like to mount them with a Keystroke, check out FastScript which lets you configure AppleScript Actions as Shortcuts.

SideShowCoder