How to make a login script for Mac OS by creating an executable command file
So after I completed the short script on how to mount SMB shares to folders from Terminal in MAC OSX I mentioned you could put that within a file and then execute it upon login to have this automatically spark up and run your mounting script each time the user logs in, See this post here Snow Leopard & mounting smb shares to folders , my plan is to ellaborate a little here and show you also how to create the script make it executable and then make it start upon login for a specific user :). Here goes.
1. Lets create the command file.
Open Terminal (Applications -> Utilities -> Terminal) then create the file in your home directory by running the following
pico filename.command [enter]
Once in type in your script to become a executable command and hold CTRL and press O then CTRL and X to exit your pico window.
Remember to put #!/bin/bash at the beginning to prevent output from your command.
2. Now lets turn this file into an executable.
ok we will CHMOD the command file to enable execution of the file. run the following
chmod +x filename.command [enter]
Job done! your file is now executable.
3. Here is the optional final step to make this launch from a user logging in on mac.
Go to System Preferences > Accounts > Select the account > Login Items
Then you can either drag and drop your command file into the login items OR you can click the + and navigate to the file that way.
NOTE: you may need to run sudo chmod +x filename in some situations instead of just chmod +x
Cheers