Benches macOS

15

Run bash script other than from terminal?

apple Verified

Imported from the Apple Support Forums via the Wayback Machine 🔗

Hi,

I have a small 2 line script that runs an application...I want to create an icon to double-click to run the 2 lines and start the app, so I don't have to open Terminal and type the 2 lines.

I've used Automator to create an app to do this, but in the task bar I see "run shell script" and the rotating wheel-thingy the whole time the app is open.

Is there any way to create a script/app to do this without having "run shell script" and the rotating wheel-thingy going on?

Cheers,

Nige

15 replies

Sign in or join Beachball Help to reply.

  1. 0

    baltwo

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Try the Automator forum or the AppleScript forum under OS X Technologies. The "do shell script" AppleScript function does what you want.

  2. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

  3. 0

    Barney-15E

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Open the Script Editor and save this as an application, after putting the name of your app in the quotes:

    tell application "name of app"
    launch
    end tell

  4. 0

    nigelj

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks Barney...but as the tell command is running my automator app that calls the bash script, I still see the 'run shell script' and rotating thingy in the menu bar.

    What I need to do is put the 2 command lines for my bash script to launch the app into a script file (sorry about my terminology here!)...in Windows you'd create a .bat file and fun that, but what's the Mac equivalent?

    Nige

  5. 0

    ericmeyers

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Save your shell script with a .command extension. Be sure it has a #!/bin/bash or equivalent as the first line.

    You can then double click it in finder.

  6. 0

    Barney-15E

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I didn't mean to put the script in as the application. I meant to put the app your script is trying to launch into the Applescript and use the applescript instead of your bash script.

  7. 0

    nigelj

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Barney/Eric,

    Excuse my lack of knowledge...I've only been using the mac for 4 months!

    I've tried both your suggestions...

    Barney...the app is actually a .sh file...it won't run in the tell command and I get the error "...you can't run...because the classic environment is not supported"

    Eric...I created a .command file using nano, but it won't run because it says I have insufficient privileges (I don't...I'm the administrator!)...this is my script...

    #!/bin/bash

    cd /Applications/jxProject

    bash /Applications/jxProject/jxProjectStart.sh

    What do I try next?

    Nige

  8. 0

    orangekay

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    chmod +x /path/to/file.command

  9. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    I would again like to suggest you look at Platypus.

    <http://www.versiontracker.com/dyn/moreinfo/macosx/19870&gt;

    Platypus is free.

    It will take your shell script, and wrap it in a double clickable application.

    Platypus is a very useful utility for anyone that likes to use traditional Unix scripting languages.

  10. 0

    nigelj

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Thanks Orangekay...my .command file is running fine now.

    Thanks Bob for the recommendation...I'll take a look!

    Nige

  11. 0

    fguzman07

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    ericmeyers wrote:

    Save your shell script with a .command extension. Be sure it has a #!/bin/bash or equivalent as the first line.

    You can then double click it in finder.

    Eric,

    I have a very problem similar to Nigelj. I've done what you say and my script runs, but it unnecessarily opens a terminal window (to run from) and leaves it behind when it is done. Since the script does not generate output and standard error is redirected to /dev/null it does not need a terminal window. Is there a way to run it without such window opening up?

  12. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    As mentioned above, get Platypus, and it will turn your shell script into a double-clickable app that does NOT open Terminal.

    Platypus is the easiest way to do this.

    Another approach is to roll-your-own AppleScript app that invokes your shell script, using Script Editor.

    You could also create an Automator workflow to turn your shell script.

    Did I mention Platypus. It is free to download, it is easy to use, and works very well.

  13. 0

    Jeff Berman

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Hmm, why does the word "Platypus" keep running through my head?

    Bob, I'm trying to do the same thing (create a .app to launch a unix application) and I also ran into the aesthetic issue of the spinning gear in the menu bar for the entire time the app was running. Since the unix app I'm running is a Usenet news reader, that spinning gear would be a long-term distraction. I'll check out Platypus, but I and probably the others in this thread are trying to learn how to do this stuff ourselves to further our OS X knowledge, not merely to solve this one problem.

    So with that being said, does anyone know if there's a way to create an Automator "Run Shell Script" action with that spinning gear in the menu bar suppressed? You know, besides using Platypus. 🙂

  14. 0

    BobHarris

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Well Automator does have:


    Library: Automator
    Action: Run Shell Script

    Using Applications -> Applescript -> Script Editor you would create an Applescript similar to the following:


    do shell script "/path/to/shell/script/to/run arg1 arg2 ..."

    Message was edited by: BobHarris

  15. 0

    Jeff Berman

    Imported from the Apple Support Forums via the Wayback Machine 🔗

    Yup, that does it. It still creates a launch process (the "do shell script" process, I guess) that stays running until the application it launches terminates, but that's way better than that spinning gear in the menu bar.

    Thanks!