Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

djRA

macrumors newbie
Original poster
Nov 30, 2009
4
0
I have a binary buried in a deep path (ex: /Library/Path/to/Folder/Application.app/Contents/MacOS/execBinaryFile) and I would like to be able to run this execBinaryFile in the Terminal.app without having to type in the whole path.

The solution I have in mind is to place an alias somewhere that the Terminal will look up. For example, the "asr" command is accessible in Terminal no matter which folder you are currently in. Using "which asr" command, it points to /usr/sbin/asr file. I assume that whatever is in /usr/sbin/ can be accessed no matter what folder you're currently at in Terminal but I don't think we are allowed to place user files in "/usr/sbin".

Is there another place to put an alias to the sample "execBinaryFile" in to make it accessible from anywhere like "asr" and other system commands?
 
The paths searched for executables is set via the PATH variable. Note that it is not the Terminal doing this, rather the shell you execute. You could add the directory containing your new command to PATH in your .login file. Or you could create the alias there.
 
Thanks, robbieduncan. I have a follow-up question:

When I pack this application in an installer, is it OK to change the PATH variable during installation?
 
Thanks, robbieduncan. I have a follow-up question:

When I pack this application in an installer, is it OK to change the PATH variable during installation?

Yes, probably, although you should probably look at changing the system/global path in that case. You might want to have a look at this...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.