Forums | MacLife
You are not logged in.
#1 2006-12-16 11:28 pm
Running a terminal command at start up
Can someone give me an idiots guide on how to execute this command at start-up for a single, auto-login user?
/Applications/synergy-1.3.1/synergyc -f 192.168.1.51
Thats all i want to do and have no idea how to make a script and the like to get it into the startup items.
Offline
#3 2006-12-17 10:47 am
Re: Running a terminal command at start up
I tried, but the first two options did not work because i most likely did them wrong. I'm interested in setting up the 3rd option to launch a startup script from the Startup Items.
Offline
#4 2006-12-17 11:58 am
Re: Running a terminal command at start up
Once you have an executable script, you should just be able to select it from the login options.
Offline
#5 2006-12-17 1:18 pm
Re: Running a terminal command at start up
if you want the their option then just create an apple script, i created and applescript and it does just that, though i don't make it run at login because i need to switch between different synergy servers
Code:
try
do shell script "killall .synergyc "
end try
do shell script "/Users/edman007/.synergyc --name lappy mr-slack"adjust the command line options and the path to synergy, compile that as an application, and then set the application as a login item
Offline
#6 2006-12-17 1:47 pm
- mahakali
- anti-razor

- From: easter egg
- Registered: 2002-11-06
- Posts: 5592
Re: Running a terminal command at start up
I'm assuming he wants it to run when the mac boots up, not when he logs in. Step #1 on the link should do that. I don't know why it doesn't do that. Did you carefully follow each step?
1. Instill fear.
2. ???????? (use your imagination)
3. Profit!
Offline
#7 2006-12-17 2:35 pm
Re: Running a terminal command at start up
he said
I'm interested in setting up the 3rd option to launch a startup script from the Startup Items.
from the link you posted
There are three different ways to automatically start Synergy (client or server) on Mac OS X:
1. ....................................
2. ..................
3. The third method is to launch a startup script from the "Startup Items" tab under System Preferences -> Accounts.
Pros:
Does not require root (Administrator) access
Cons:
Once the user logs out, synergy dies, and no remote control is possible.
i guess when you put a space in "Startup Items" it means login, while "StartupItems" means on boot
Offline
#8 2006-12-17 4:13 pm
Re: Running a terminal command at start up
Putting shell commands in an AppleScript is kind of overkill. If you merely put this in a text file
Code:
#!/bin/sh killall .synergyc /Users/edman007/.synergyc --name lappy mr-slack
open the terminal and type "chmod +x ", drag the file over, and press enter, you'd be good to go.
Offline
#9 2006-12-17 5:59 pm
Re: Running a terminal command at start up
but that opens the terminal to run the command, apple script is a little nicer, right now i just have the icon on my dock, i click it, it bounces once, and its done, to my knowlage you can't put a shell script on the dock and execute it without opening anything else, thats why i use applescript for it
Offline
#10 2006-12-18 8:27 am
Re: Running a terminal command at start up
edman007 wrote:
if you want the their option then just create an apple script, i created and applescript and it does just that, though i don't make it run at login because i need to switch between different synergy servers
Code:
try do shell script "killall .synergyc " end try do shell script "/Users/edman007/.synergyc --name lappy mr-slack"adjust the command line options and the path to synergy, compile that as an application, and then set the application as a login item
Thanks, this is exactly what i was looking for.
I only needed a script i could set to run when the computer boots up and it auto logs me in. I knew i could make an app in automator, i just didn't know what to slap in there. Thanks again sir 
One thing though, is it supposed to keep running up in the menu bar with a red light and the words "Run Applescript" next to it?
Last edited by Avari (2006-12-18 8:28 am)
Offline
#11 2006-12-18 12:21 pm
Re: Running a terminal command at start up
what i did was open the Script editor in the /Applications/Applescript, then paste and edit what i posted, then go file->save, select application as the format, and leave all checkboxes unchecked, and then save that, then when running it, it will just bounce once on the dock and dissapear
Offline
#12 2006-12-19 7:55 pm
Re: Running a terminal command at start up
edman007 wrote:
what i did was open the Script editor in the /Applications/Applescript, then paste and edit what i posted, then go file->save, select application as the format, and leave all checkboxes unchecked, and then save that, then when running it, it will just bounce once on the dock and dissapear
Still just sticks in the dock trying to keep connecting to the server, i just force quit it when i'm done with it. Its actually good this way. I ditched the keyboard and mouse switch, so if i boot my mac up first i don't have to worry about it because it will keep trying to connect till i boot up my PC.
Offline
#13 2006-12-19 8:43 pm
Re: Running a terminal command at start up
if you put the `-f` or `--no-daemon` in the command to run synergy it might cause that, applescript exits when the program finishes, with those flags then synergy will never exit and the applescript would then just sit on the dock. Without the above flags synergy will run in the background, this means it will exit when applescript runs it (it of course will still run in the background and always try to connect) but the applescript will get to do other things, such as stop taking up space on the dock and quit
Offline
#14 2006-12-20 9:46 am
- TheMouthOfSauron
- Member
- From: The Pas, MB, Canada
- Registered: 2002-02-25
- Posts: 659
Re: Running a terminal command at start up
Try this:
Code:
try
do shell script "killall .synergyc "
end try
ignoring application responses
do shell script "/Users/edman007/.synergyc --name lappy mr-slack"
end ignoring"Infinity is not a number! Infinity simply describes the way in which this [function] does not exist."
-Alex Chigogidze
Offline
#15 2006-12-22 4:46 pm
- reepicheep
- Member
- Registered: 2006-12-22
- Posts: 23
Re: Running a terminal command at start up
sudo vi /etc/rc
*highly unsafe
Offline
#16 2007-01-07 12:14 am
- Kosh
- The Enigmatic One

- From: Somewhere on or near Earth
- Registered: 2003-01-18
- Posts: 633
Re: Running a terminal command at start up
reepicheep wrote:
sudo vi /etc/rc
*highly unsafe
**Shudder**
Um, quite (in other words, don't do that if you don't know what you're doing!).
If you want to run the script at boot-time, just use Cron; it's much safer. For example, type "crontab -e" into a terminal window, then type the following on a new line:
Code:
@reboot /path/to/synergyc -options
Then, to exit the editor, type ":wq" (without the quotes).
Make sure to get the executable / path correct, as well as whatever options you need.
Note that this method will likely run before DHCP, etc is available (as the linked note comments on), so unlike the StartupItem method, you might need to specify IP address instead of a name.
They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.
-- Benjamin Franklin, 1759
Offline
#17 2007-03-04 4:50 am
Re: Running a terminal command at start up
Kosh wrote:
If you want to run the script at boot-time, just use Cron; it's much safer. For example, type "crontab -e" into a terminal window, then type the following on a new line:
Code:
@reboot /path/to/synergyc -optionsThen, to exit the editor, type ":wq" (without the quotes).
Make sure to get the executable / path correct, as well as whatever options you need.
Note that this method will likely run before DHCP, etc is available (as the linked note comments on), so unlike the StartupItem method, you might need to specify IP address instead of a name.
i tryed that but it didnt work QQ i have synergyc in /usr/bin its works fine in the cli but i cant get
Code:
@reboot /usr/bin/synergyc 192.168.1.103
to work, i own the file... i need help plz !! oh and this is on debian with KDE
[MA]NoExit|X| - The good man scorns the wicked.
Offline
#18 2007-03-05 9:28 pm
- ElectricSheep
- Member
- Registered: 2003-07-20
- Posts: 109
Re: Running a terminal command at start up
Another method not mentioned by anyone yet is to use Mac OS X's built in Launch Services. Launch Services is the future of launching daemons and processes at startup, login, or on a schedule. It replaces the functionality of rc, cron, and SystemStarter (Startup Items). Unfortunately, as powerful as Launch Services is, Apple hasn't provided an easy way for the end user to take advantage of it.
A 3rd party piece of freeware, Lingon, offers an easy wizard-based way of adding an agent or daemon to be controlled by Launch Services. You could use it to easy have synergy start at login, startup, or a particular time of day. Plus, if for whatever reason synergy crashes Launch Services is designed to re-launch it and keep it running automatically.
Last edited by ElectricSheep (2007-03-05 9:28 pm)
Offline
#19 2007-03-05 9:49 pm
- Nefarious
- Tuning Fork
- Moderator

- From: 45°22"N 84°57"W
- Registered: 2002-09-30
- Posts: 7998
Re: Running a terminal command at start up
Keyboard Maestro
Offline

