How do I execute this command at start up in OS X?
December 13, 2007 2:31 PM   Subscribe

OS X-filter: I've been searching but having a hard time finding an answer anywhere. I have a command I put into the terminal each time I boot my Mac that disables some third party firewall I can't find to delete. I'd like a shell script that would launch and just execute the command each time I start up my computer.

I've made a script.sh file and put it in the "start up items", but it just launches my text editor. heh.

So what's the best way to execute something like:

sudo ipfw add 0 deny udp from any to any 4550

when I start up, friends?
posted by mattoly to Computers & Internet (8 answers total) 2 users marked this as a favorite
 
How did you edit it? Is it possible that it's actually script.sh.txt, and the .txt isn't showing? If you know how to use vi or emacs, try using that instead; otherwise, use nano (just run "nano" at the command line - it's pretty self-explanatory). Also, check that it's executable - "chmod a+x script.sh" should do it, I think.
posted by spaceman_spiff at 2:43 PM on December 13, 2007


The google search term you're looking for is "launchd" -- you'll find lots of tutorials for creating a launchd plist by hand, or there's apparently a shareware gui you can use (which I haven't tried personally).
posted by ook at 2:52 PM on December 13, 2007


You need to create a launchd item to check run the script at boot. It involves creating a file in /Library/LaunchDaemons/ which will call your script at boot time. You can read up on it here. This is the 'good' way to do it.

Also check /System/Library/LaunchDaemons or /Library/LaunchDaemons as the firewall that you are looking to bypass would have had to install itself there in order to launch at start also. (if it is not in startup items either).

Also the command runs at root via launchdaemons, so you don't need the sudo command.
posted by mrzarquon at 2:56 PM on December 13, 2007


I can;t provide a exemplary answer but i setup a coworkers computer to start synergy on startup and i remember it took me like 2.5 hours of googling and script work to set it up.
posted by DJWeezy at 3:19 PM on December 13, 2007


Would it work to do it this way?
- open a new text file in TextEdit, convert to plaintext (Format -> Make Plain Text)
- paste sudo ipfw add 0 deny udp from any to any 4550 into it
- save as whatever.txt
- in the finder, rename it to whatever.command (making sure it's not actually "whatever.command.txt" with the extension hidden)
- drag-and-drop whatever.command to your login items (System Preferences -> Accounts -> Login Items)

Unrelated; DJWeezy I was really confused that you had so much trouble auto-starting Synergy until I realized you probably meant this synergy and not this synergy.
posted by churl at 4:13 PM on December 13, 2007


Lingon (google it) is a gui for creating launchd items.
posted by singingfish at 6:04 PM on December 13, 2007


Response by poster: Thanks everyone, this helped. I got it working. :)
posted by mattoly at 7:02 PM on December 13, 2007


Call me crazy, but:

>some third party firewall I can't find to delete

you installed a third-party firewall on your Mac and now you don't know how to delete it? Wouldn't you rather have our help with that instead?
posted by AmbroseChapel at 6:13 PM on December 15, 2007


« Older Easy way to make great-looking charts and graphs?   |   Why does Subwayâ„¢ stink? Newer »
This thread is closed to new comments.