Benches macOS

4

Run a simple shell (.sh) script as a Logi…

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

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?

4 replies

Sign in or join Beachball Help to reply.

  1. 0

    Mark Jalbert

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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.

  2. 0

    CRoth2

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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"

  3. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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}

  4. 0

    CRoth2

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    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"