Path to excutables in shell scripts

Hey Jimmy,

Run this from a Keyboard Maestro Execute Shell Script Action and display text.

echo $PATH

You'll see something like this:

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

Quite obviously it does not contain your path /usr/local/bin/…

Keyboard Maestro ignores your bash profile or .profile configuration when it instantiates a shell (as does AppleScript).

You can hardcode to that path in your command:

/usr/local/bin/compare

But the better way in my opinion is to adjust the path as needed in your script thus:

export PATH=whatever/you/want:$PATH

In your case:

export PATH=/usr/local/bin:$PATH;

That way you don't have to write the entire path to the command, and your code reads much easier.

-Chris

3 Likes