How to run a script at startup?

rformiga

Registered
Hello everybody!

First of all let me apologize for my *not so good* (not to mean bad) english. I have a little problem here and maybe you Unix guys can help me out. I need to run a script during the Jaguar startup. At the moment, everytime I turn on and log in my iMac I have to open the Terminal and type "sh" + the script name (so, I run it manually). Once it finishes I quit the Terminal app and begin my work. The point is: it is extremely boring to this all the time. So, is there any way to make this procedure automatic?

Thanks!
- Roberto
 
You could create an applescript and then have the applescript program at startup.

I don't know applescript myself, but if someone does, there's the idea.
 
You are trying to run a shell script that doesn't need to be a service (in which case you'd put it in /System/Library/Startupitems). So you can simply put the call to the sh file in your .bashrc if bash is your shell, or .tcshrc/.cshrc if tshell or cshell is you shell.

If it sets env vars you'd need to 'source' the file ((t)csh) or '.' the file (bash).

Cheers,

Brooke
:cool:
 
Another idea, which should work just fine, is to make the script a clickable file by

1. Making sure it starts with a shebang (for instance, "#!/bin/sh")
2. Chmodding it properly (755 or so)
3. Changing the name to end in .command (for instance, "myscript.command")

At this point you have a script that you could leave on your desktop or in your dock and run by clicking on it. Similarly, you should be able to add it to your startup applications in the Login Items preferences pane.
 
Back
Top