Simple Pandoc Command Not Running in KM Shell Script Macro

OK, so I am probably missing something simple, but here goes.

This script runs perfectly in Terminal:

cd /Users/Path/To/Resources
pandoc My-Presentation.md -o My-Presentation.pptx --reference-doc=template.potx --slide-level=2

I have Pandoc installed, and when running that command, I can convert my MarkDown file to Powerpoint from a template flawlessly.

If I paste that exact same script into a Shell Script and run it:

... it errors, and states:

2023-02-06 23:48:24 Execute a Shell Script failed with script error: text-script: line 2: pandoc: command not found. Macro “Trying” cancelled (while executing Execute Shell Script).

Have I missed a step that allows me to run this command which works perfectly inside Terminal?

The Keyboard Maestro shell environment and your Terminal shell environment are very different.

The most obvious difference, and at least the start of your problems with this script, is the PATH setting.

See: Execute a Shell Script — Path in Shell Scripts.

3 Likes

and in particular here, you need to provide the full path to the pandoc executable.

(plain pandoc at the start of your second line won't be enough in a vanilla shell)

The command line incantation:

which pandoc

will, of course, remind you of the full path to pandoc.

2 Likes

A post was split to a new topic: Execute Shell Script Action Fails to Increase macOS Contrast