14

I have a very simple automator action consisting on a shell script that should be executed in a selected folder in the finder. When I execute the action I get the message:

The action "Run Shell Script" encountered an error.

Obviously this is too generic. Is there an easy way to see a more precise error message that give me a clue of what the problem is about ?

9

Enable the Automator Log

Automator's Log panel should display more detailed error information. You can show it by clicking the Log item in the View menu (or pressing ⌥⌘L).

Log Panel

4
  • 8
    but I am not executing the action in the Automator editor with the 'Run' button, but directly in the Finder. There is no way to see the error if the action is executed in the Finder ?, otherwise how can I execute it in the automator editor if the action takes a parameter a selected folder ?
    – Sergio
    Oct 30 '12 at 22:17
  • 2
    Yes, you can run it in the Automator editor and the "Selected Finder Items" action just uses whatever is selected in the frontmost Finder window, even if that's not the active window.
    – robmathers
    Oct 30 '12 at 22:34
  • At 2016-01-07 on MacOSX 10.10 using this method for testing scripts that rely on "Selected Folder Items" does not work on my device. Jan 6 '16 at 20:04
  • 3
    You can fake having items selected in Finder by introducing Get Specified Finder Items as the first step of your workflow. Pick a few sample items and push Run.
    – duozmo
    Jan 13 '16 at 23:04
5

If you need to debug workflow outside of Automator.app, then syslog command can be used.

Say you made Quick Action workflow with Run Shell Script action like below:

for f in "$@"
do
    syslog -s -l i "Touching file: $f"
    touch "$f"
done

"Quick Action" workflow

Now you can use Quick Action in Finder:

Running "Quick Action"

Output of syslog command can be viewed in Console.app:

Output of Syslog command

Another way to view output of syslog command – is to use log command in Terminal.app.

log stream --info --debug --predicate 'process == "syslog"'

log command in Terminal.app


Update

We can improve Quick Action shown above by sending local notification on successful completion:

for f in "$@"
do
    syslog -s -l i "Touching file: $f"
    touch "$f" || exit 1 # Early exit on failure.
    osascript -e "display notification \"Touched file: $f \" with title \"Automation\""
done

Local notification

1
  • notification adds a really nice touch! thank you.
    – Vibin
    Jun 25 '20 at 10:23
1

If you're willing to use JavaScript via the Run JavaScript action rather than shell scripting, you can get pretty great step-through debugging features that web devs nowadays are used to, i.e. the Web browser Inspect panel (in this case Safari's). Setup guide available in Apple's docs on debugging Automator JS.

Setup is simple and as of this comment is verified working on Big Sur.

You must log in to answer this question.

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