Run .command with input at runtime

command lineterminal

I need to run a .command file with input at runtime, but I want to run via double click, not from terminal.

I have a file adbInstall.command file with this code

adb install /Directory/$1.apk

From terminal, I can do adbInstall.command fileName and it will properly run adb install /Directory/fileName.apk

How can I input fileName whilst double clicking on adbInstall.command instead of running it from terminal?

Best Answer

Using Automator.app:

  1. Open Automator and create a new Work Flow
  2. Go to Actions / Library / Text
  3. Choose Ask for Text and enable the Require an answer checkbox.
  4. Go to Library / Utilities
  5. Choose Run Shell Script
  6. Select as arguments on the pass input: drop down.
  7. Type adb install /Directory/$1.apk as the actual script.
  8. Save as Application.

Now you'll have a clicable file which will ask for the parameter for the script.