Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Run a simple shell (.sh) script as a Login Item

So here is the situation...all I want to do it start up and connect my synergy client when I login to the machine. I have a small shell script that does this. It looks like:

#!/bin/sh

# Start synergy and connect to basd-wd-19870
/Applications/synergy-1.3.1/synergyc basd-wd-19870


The "basd-wd-19870" is the name of my workstation the client should connect to. This is why I can't simply select the executable itself. When I run the "synergy.sh" file, it simply opens as a TextEdit file. I did "chmod 744 synergy.sh" and this runs fine from terminal.

I am trying to avoid using the Login Hook as others have suggested in other topics, as I am not familiar with them and don't really want to get that complicated if I don't have to.

Any suggestions?

MacBook Pro 15, Mac OS X (10.6.2), MacBook Pro 15, iMac 20 lab, xserves, AD integration

Posted on Apr 13, 2010 5:52 AM

Reply
4 replies

Apr 13, 2010 8:15 AM in response to Mark Jalbert

Mark Jalbert wrote:
You could try to add your script in System Preferences > Accounts > Login Items. Or run the the script with launchd as a $HOME/Library/LaunchAgents.


I can't believe I didn't specify. Sorry. I did try the System Preferences > Accounts > Login Items. That is actually where I got the part of my message that said it just opened TextEdit. In login items synergy.sh is shown as a "Plain Text".

I don't know how to use the launchd items. Would this just run it for me? I don't want it to run for anyone who logs into the machine.

NOTE: The "#" sign in the original post quoted text go changed to a "1.". It should read "# Start synergy and connect to basd-wd-19870"

Apr 13, 2010 10:50 AM in response to CRoth2

I can't believe I didn't specify. Sorry. I did try the System Preferences > Accounts > Login Items. That is actually where I got the part of my message that said it just opened TextEdit. In login items synergy.sh is shown as a "Plain Text".

Change the suffix from .sh to .command

This should cause the script to launch the terminal and then run the script. The .command suffix will also make the script double-clickable.

However, as a side effect, it will launch the terminal, which may not be something you want.

You can use an Applications -> Automator workflow using the "Run Shell Script" automator action to run your script WITHOUT starting the terminal. Save the Automator workflow as an applications, and drag this to the Login Items.

You can also download the free Platypus and turn any script into a double clickable application which can be placed in the Login Items.
NOTE: The "#" sign in the original post quoted text go changed to a "1.". It should read "# Start synergy and connect to basd-wd-19870"


Wrap your code segments in a pair of
tags

...
... your code here ...
...
{code}

Apr 13, 2010 12:05 PM in response to BobHarris

BobHarris wrote:
You can use an Applications -> Automator workflow using the "Run Shell Script" automator action to run your script WITHOUT starting the terminal. Save the Automator workflow as an applications, and drag this to the Login Items.


Bob, this worked exactly as advertised! Thanks so much.

All I did was remove the "#!/bin/sh"

Run a simple shell (.sh) script as a Login Item

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.