You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator - BASH environment variables

Hi Automator experts,


I am trying to accomplish a rather simple image conversion from within Automator using a command-line program (epstopdf). I wrote a shell script which does work when invoked from the command line inside a directory with EPS files. It is listed below


---------------------------------

#!/bin/bash

for file in *; do

if [[ $file == *.eps ]]; then

/usr/texbin/epstopdf "$file"

fi

done

---------------------------------


I thought that it would be nice to use Automator to turn this either into a service or application. To test it from within Automator, I added the "Get Specified Finder Items" and populated the list with some test EPS files. This action was then connect to "Run Shell Script" with "/bin/bash" as shell and "as arguments" for the input. The shell script is listed below


---------------------------------

. /Users/langrock/.profile # makes environment variables available


for file in "$@"; do

if [[ $file == *.eps ]]; then

echo "$file"

/usr/texbin/epstopdf "$file"

fi

done

---------------------------------


When commenting out the /usr/texbin/epstopdf "$file" line, the script runs and correctly displays the files with their full paths. Yet, when I try to actually pass these files to the epstopdf command, I get an error message.


sh: gs: command not found


I get this error despite sourcing bash's PATH variable in the first line of the script as shown above. Running an 'echo $PATH' in this script results in the correct output, showing the path where the 'gs' command can be found (/usr/local/bin/). I am at a complete loss here even after searching the great wide internet for a solution.


Any pointers to what I could try next would be appreciated. If nothing works, I might try setting up a Python script instead.


Thanks

MacBook, Mac OS X (10.7.5)

Posted on Jul 30, 2014 5:51 PM

Reply
2 replies

Jul 30, 2014 6:48 PM in response to Carsten Langrock

sh: gs: command not found

I assume is "GhostScript".


Is that also in /usr/texbin/ ???


If so /usr/texbin/ is NOT in your PATH.


So maybe you want to provide your own PATH in your script


export PATH=$PATH:/usr/texbin


And if gs is not in /usr/texbin/ then provide the PATH information for hwere it is located.


The point is that Automator does get your shell initialization script and PATH modifications.

Automator - BASH environment variables

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.