TL;DR If I create a .app via Automator, how can I show results of a shell script in a dialog or terminal window?

I am using Automator to run a shell script

adb install /Directory/$1.apk

and if I run it via Automator, I can see the results (install successful or can't find filname.apk or whatever else terminal would tell me). If I save as app and double click to run, then I do not get to see these results.

What can I do to show a dialog or terminal window that would display the results of the script I run?


4 Answers 4


There are a couple of ways you could do this:

  • Adding an Ask for Confirmation action after the Run Shell Script one and using $1 in the message field.
  • Adding another Run Shell Script and executing osascript -e 'tell app "System Events" to display dialog "$1"'. You'll have to select as argument on the pass input drop down.
  • 13
    It just displays $1 with either of those methods.
    – Reed
    Commented Jan 11, 2014 at 19:21
  • @Jakar I've tested it having the first Run Shell Script action doing echo something and it definitely works. Perhaps you're Script is not returning something?
    – Thecafremo
    Commented Jan 11, 2014 at 23:30
  • Okay. I'm thinking it may have something to do with adb (part of Android developer SDK), because there is output in Terminal after I run that command, but not via the automator script.
    – Reed
    Commented Jan 12, 2014 at 3:37
  • 1
    Slight modification to handle the string interpolation osascript -e 'tell app "System Events" to display dialog "'"$1"'"'
    – bingles
    Commented Oct 28, 2015 at 14:52
  • Trying the 1st method, not oascript. something as simple as md5 $file, and I have it set "as arguments', but no matter what I try, all it outputs is "$1", not the md5 results. (I tried $file for the output, and that doesn't work either) Commented Apr 9 at 8:01

If you only have a few lines of output, you'd want to assign it to a variable and then display a confirmation dialog showing the output.

  1. add Action "Set Value of Variable"
  2. enter a new variable, e.g. output
  3. add Action "Ask for Confirmation"
  4. in the message field, enter the variable name declared above. While typing the variable name, Automator will suggest to complete the variable name. Accept by pressing Enter key. This prevents Automator from interpreting the variable name as a plain text message.

This will look like this: Automator with text output

NB: I also tried the $1 approach, but did not succeed.

If you have a lot of lines of output, you should direct all output into a new TextEdit document. To do so, just add the "New TextEdit Document" Action after your script action.

This may look like this: New Text Edit document action

Hint: diagnostic messages are often output to standard error. To also collect text send to standard error, add exec 2>&1 at the top of your bash script.

  • 1
    wow exactly what I needed !
    – code4j
    Commented Jan 10, 2016 at 13:05
  • 1
    this solution worked for me whereas the accepted version did not Commented Jan 30, 2016 at 10:13
  • this was really useful to me and explained why I couldn't get the value of the output. great job
    – CommentLuv
    Commented Feb 27, 2017 at 12:25
  • Can this be modified to open a TextMate document?
    – Greg
    Commented Aug 28, 2019 at 19:05

Need to use "Set Value of Variable"

enter image description here

  • Tempted to downvote because this is just a duplicate of Daniel K's answer, except with less information...
    – adfaklsdjf
    Commented Nov 6, 2019 at 17:17
  1. Add action "Run AppleScript"
  2. Paste this script:
on run {input, parameters}
    display dialog input
end run
  • 1
    display dialog is a part of Standard Additions in AppleScript and there is absolutely no need whatsoever to be using tell application "System Events" to in this use case. Commented Nov 22, 2021 at 2:08
  • @user3439894 Thanks, that's terser. Edited.
    – cakraww
    Commented Nov 22, 2021 at 2:18

You must log in to answer this question.

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