Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Could someone please tell me how to insert a terminal command into an "application" so when the app is clicked/opened the command is launched?

share|improve this question
1  
What is it, explicitly, that you're trying to accomplish? There are several ways to do what you're asking, AppleScript, Automator or third-party Platypus. – user3439894 Feb 21 at 22:51
    
um I'm trying to put an terminal command in an app so when open all the apps will open so my old computer won't work any more. pretty stupid way to crash it, but please don't judge – Ethan McKinley Feb 21 at 23:00
    
What is the actual command you're wanting to execute? – user3439894 Feb 21 at 23:13
    
find /Applications -name *.app -prune -exec open {} \; – Ethan McKinley Feb 21 at 23:17

Open Automator and choose Application for the document type.

Add a Run Shell Script Action.

Add your command line to the Run Shell Script Action so it's the only command in the action.

Save it as an Application to the desired location giving it whatever name you want.

enter image description here

share|improve this answer

Instead of an application, you could always try writing a bash script.

To write and run a bash script, there are a few things to do:

  1. Open TextEdit from /Applications/Utilities/TextEdit.app and then
    press shiftcommandt (⇧⌘T) to convert it into a plain text document.

  2. Insert a shebang as the first line:

    #!/bin/bash

  3. Add your command below it. In the end, your script should look like:

    #!/bin/bash
    <your command here>

    Then save the script.

  4. In Terminal, do chmod 775 /path/to/your/script

  5. To run your script, either click on the file (which should now have an executable icon).

share|improve this answer
    
For some reason SE doesn't allow me to escape the hash but interprets it as a title character. Thanks for pointing out the plaintext mistake. – perhapsmaybeharry Feb 22 at 0:08
    
I've made edits to have it show properly for you. – user3439894 Feb 22 at 1:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.