Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

GNice

macrumors 6502
Original poster
Aug 7, 2007
479
0
I have a very simple (one line) shell script that does nothing but create a symbolic link. I've given it execute permissions and tested it. Works like a charm from the command line. Being still pretty new to the mac world I googled around and it appears LoginHook is the way to get a script to run at start up. I followed the instructions found here: http://docs.info.apple.com/article.html?artnum=301446

Tried both approaches...with no success.

I also tried the tool located here: http://www.bombich.com/mactips/loginhooks.html

I got a few messages about not being able to find certain files, but the UI came up and I was able to point to my script test it and it worked. But once again after a reboot, my script didn't run at log in.

Anyone have any idea if LoginHook still works in Leopard (all info I could find was pre-Leopard). Any other suggestions on how to get a shell script to run at start up.

Thx!
 
I have a very simple (one line) shell script that does nothing but create a symbolic link. I've given it execute permissions and tested it. Works like a charm from the command line. Being still pretty new to the mac world I googled around and it appears LoginHook is the way to get a script to run at start up. I followed the instructions found here: http://docs.info.apple.com/article.html?artnum=301446

Tried both approaches...with no success.

I also tried the tool located here: http://www.bombich.com/mactips/loginhooks.html

I got a few messages about not being able to find certain files, but the UI came up and I was able to point to my script test it and it worked. But once again after a reboot, my script didn't run at log in.

Anyone have any idea if LoginHook still works in Leopard (all info I could find was pre-Leopard). Any other suggestions on how to get a shell script to run at start up.

Thx!
A work-around is to save the shell script as a command file (example: login.command), make it executable, then add it to your Login Items in System Preferences -> Accounts pane.
 
Thx soooo much! Worked like a charm. Now as I final touch if I can just "automatically" close the terminal window that gets launched when the script is run I will be golden.

Too bad the LoginHook isn't working, but I definitely appreciate your help!
 
Thx soooo much! Worked like a charm. Now as I final touch if I can just "automatically" close the terminal window that gets launched when the script is run I will be golden.

Too bad the LoginHook isn't working, but I definitely appreciate your help!
That's easy too. Just add the following line to the end of your script:
Code:
killall Terminal
You may get a warning from the Terminal that stuff is running, but you're probably going to want to disable that. I've attached a couple of screenshots. The first one is the default settings in Leopard's Terminal. The second one is what you want the settings to look like.
 
You can close the terminal window without closing the whole program by using a simple AppleScript:

Code:
osascript -e 'tell app "Terminal" to close every window whose frontmost is true' &

This works from the terminal.

Bonus:
If you've got scripts etc. that keep running all the time you can easily turn them into "daemons" with GNU screen utility

Code:
screen -dmS "Name" /path/to/script.something

After this command it's safe to close the whole terminal and the script keeps still running.

Name is for indentification purposes only, if you've got multiple screens running it's useful. leave -S away if you don't wanna spefify a name.

Ville
 
You can close the terminal window without closing the whole program by using a simple AppleScript:

Code:
osascript -e 'tell app "Terminal" to close every window whose frontmost is true' &

This works from the terminal.

Bonus:
If you've got scripts etc. that keep running all the time you can easily turn them into "daemons" with GNU screen utility

Code:
screen -dmS "Name" /path/to/script.something

After this command it's safe to close the whole terminal and the script keeps still running.

Name is for indentification purposes only, if you've got multiple screens running it's useful. leave -S away if you don't wanna spefify a name.

Ville
Thank you! I did not know you could do this - I write shell scripts myself, and this capability will be very useful for me.
 
Thx a million wrldwzrd89 and weatherman!!! You both have helped me a ton!!!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.