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.

Share

Tags: , , , , , , , ,

2 Responses to “How to make a login script for Mac OS by creating an executable command file”

  1. Josh April 22, 2013 at 12:45 pm #

    NOTE: you may need to run sudo chmod +x filename in some situations instead of just chmod +x

    Cheers

Trackbacks/Pingbacks

  1. Snow Leopard & mounting smb shares to folders | Tech Help Blog - March 7, 2011

    […] here is another post on how to make this script an executable file using CHMOD +x check it out here. Rating 3.00 out of 5 Desktop Tech (Apple Mac) […]

Leave a Reply