Translate shell script not working within Automator

Solution 1:

The default PATH passed to the Run Shell Script action in Automator is:

/usr/bin:/bin:/usr/sbin:/sbin

I always add a PATH=..., where ... is the actual PATH used in Terminal, to the top of the Run Shell Script action in Automator.

Or you have to add the fully qualified pathname of any executable to the command line that is not in the default PATH passed to the Run Shell Script action in Automator.


The last line in the trans script is gawk -f <(echo -E "$TRANS_PROGRAM") - "$@" and unless gawk is in the default PATH passed you'll need to add the location of gawk to the PATH you pass to the Run Shell Script action in Automator, or add the fully qualified pathname to the gawk command at the end of the trans script.

In Terminal use which gawk to get its path, e.g.:

which gawk
/usr/local/bin/gawk

In trans, change:

gawk -f <(echo -E "$TRANS_PROGRAM") - "$@"

To:

/usr/local/bin/gawk -f <(echo -E "$TRANS_PROGRAM") - "$@"

Or in the Run Shell Script action in Automator, e.g.:

PATH=$PATH:/usr/local/bin

Or use the PATH from the output of echo $PATH in Terminal.