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)