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?

2 Answers 2


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.

  • 1
    Thanks for your help. In case somebody else runs across it, I had a bash profile setup, so I also had to add source ~/.bash_profile to the script before the adb line.
    – Reed
    Jan 11, 2014 at 17:08

You could create your .command with something such as:


if [ -n "$1" ]
  read -p 'enter filename: ' thefile
  echo "filename is:" $thefile

adb install /Directory/$thefile.apk

echo "done."

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .