paths to place alias for universal access in Terminal

Discussion in 'Mac Programming' started by djRA, Dec 1, 2009.

  1. djRA macrumors newbie

    Joined:
    Nov 30, 2009
    #1
    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?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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.
     
  3. djRA thread starter macrumors newbie

    Joined:
    Nov 30, 2009
    #3
    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?
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    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...
     

Share This Page