Alternative for Bash's where command when using «do shell script»?

Tonight I have a problem:

I have written an AppleScript droplet that converts dropped PostScript files (*.ps) into PDF documents using Ghostscript. On my own PowerBook Ghostscript is installed in «/usr/local/bin/gs», but on other Macs it can be installed in different locations. That’s why I thought to first use the «where» command in order to locate Ghostscript first, before using it.

But it seems that the «where» command only belongs to Bash, as I always get the error message «sh: where: command not found» when executing code like follows:


do shell script "where gs"

So my question is: Does anybody know a «where» alternative for sh? I already googled about this subject, but unfortunately this time Google could not help me.

Thanks in advance!

Hi Martin,

does whereis gs work?

Hi Stefan,

Unfortunately not (Bash & sh). But «whereis screencapture» does work (Bash & sh). Weird.

Unfortunately there isn’t a very good solution to this. Your two options I can think of are ‘which’ or ‘whereis’.

whereis only searches the standard binary directories so if gs exists outside of that it won’t be found.

which is only searching in the user’s path so again may not find your binary.

Thank you so much Stefan and James, sometimes one has to accept defeat :slight_smile: