How to set environmental variable?

Discussion in 'Mac Basics and Help' started by hajime, Sep 28, 2013.

  1. hajime macrumors 68030

    Joined:
    Jul 23, 2007
    #1
    Hello, I am using 10.8.5. I installed a program which is supposed to do all the settings during installation. However, when I tried to use it via an xterm, I got "bash: abc: command not found". During installation, I installed it to the default directory /usr/local. Under /usr/local/abc/bin, I found some of the programs related to the one I just installed. When I tried to run the main program by doing "./abc", I got: "You need to set the ABCDIR environment variable to point to the ABC installation directory before you can run anything."

    When I typed: "less ~/.bash_profile", I found the following:

    # ABC Setup
    ABCDIR=y/abc
    PATH=${ABCDIR}/bin:${PATH}
    export ABCDIR PATH
    . ${ABCDIR}/etc/abcconf/abc.sh



    Could anybody please let me know what to do? Thanks.
     
  2. pmau macrumors 65816

    Joined:
    Nov 9, 2010
    #2
    Since you seem to be using bash, try

    Code:
    export ABCDIR=/location
    
    Before invoking your program.
     
  3. hajime, Sep 28, 2013
    Last edited: Sep 28, 2013

    hajime thread starter macrumors 68030

    Joined:
    Jul 23, 2007
    #3
    I typed "export ABCDIR=/usr/local" but I still got the same error message about the need to set the ABCDIR environment variable.

    I worry that if I make a mistake, I will mess up the system. Could you please be more explicit on what I should change in that line? I am supposed to install the program in /usr/local

    Thanks.
     
  4. pmau macrumors 65816

    Joined:
    Nov 9, 2010
    #4
    Without any detail on what you are doing we are both wasting our time.

    Let me explain some basics to you:

    If you are in a Terminal, xterm or any "shell" environment, programs are found using the PATH environment variable.

    If you type "ls -la .", the program will be found in "/bin" for example.

    The program you installed (you did not tell what kind of program) has added a few commands to your bash profile, to populate your environment with the correct settings.

    Since that did not work, you have to figure out where this is failing:
    Code:
    # ABC Setup
    ABCDIR=y/abc
    PATH=${ABCDIR}/bin:${PATH}
    export ABCDIR PATH
    . ${ABCDIR}/etc/abcconf/abc.sh
    
    To do so you have to enable script execution debugging in bash
    Code:
    set -x
    
    Now, simply copy and paste the lines above in your shell and see what happens.

    The last line executes a script: ". ${ABCDIR}/etc/abcconf/abc.sh"
    which will be the most important part of your journey.

    It's quite simple but you provide next to no information because ABCDIR and "abconf.sh" is certainly not the real thing.

    Good luck.
     

Share This Page