Results 1 to 7 of 7

Thread: Environment variables

  1. #1
    Join Date
    Nov 2011
    Beans
    16

    Red face Environment variables

    How do I create an environment variable EJBCA_HOME?
    Where are environment variables stored?

  2. #2
    Join Date
    Sep 2011
    Location
    Wherever I go, Here I am
    Beans
    Hidden!
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Environment variables

    Quote Originally Posted by Scarlet Sphere View Post
    How do I create an environment variable EJBCA_HOME?
    Where are environment variables stored?
    The kernel stores the list of environment variables and their values for each process, and inherit them to child processes. They exist at runtime, and are not stored in some file or so. But there is a virtual file in
    /proc/<pid>/environ Which contains all the environment variables. The kernel makes them visible by that virtual file. One can list them. For example to view the variables of process 3940, one can do
    cat /proc/3940/environ | tr '\0' '\n' Each variable is delimited by a binary zero from the next one. tr replaces the zero into a newline.



    -----http://stackoverflow.com
    Please mark your thread as Solved when appropriate || My WIKI
    ---------------------------


  3. #3
    Join Date
    Sep 2006
    Beans
    7,699
    Distro
    Lubuntu Development Release

    Re: Environment variables

    If you're talking about the shell, then environment variables are stored in .profile. You can use export to set the variables.

    Code:
    export EJBCA_HOME="The quick brown fox jumped over the lazy god."
    Last edited by Lars Noodén; December 9th, 2011 at 12:02 PM.

  4. #4
    Join Date
    Nov 2011
    Beans
    16

    Re: Environment variables

    Quote Originally Posted by Lars Noodén View Post
    If you're talking about the shell, then environment variables are stored in .profile. You can use export to set the variables.

    Code:
    export EJBCA_HOME="The quick brown fox jumped over the lazy god."
    I tried that but it didn't work. I tried:
    Code:
    export EJBCA_HOME="/home/user/ejbca"
    and also:
    Code:
    export EJBCA_HOME=/home/user/ejbca
    I am trying to access it by running:
    Code:
    String ejbcaHomeDir = System.getenv("EJBCA_HOME");
    Did I do something wrong?

  5. #5
    Join Date
    Oct 2009
    Location
    frisco-->native
    Beans
    324
    Distro
    Ubuntu

    Re: Environment variables

    I know very little about this topic but have an interest. I didn't know about the system command. I am wondering what the dot operating is. Does it call a child function....? I didn't see getenv in the man pages under system.

    I use
    echo $ENVAR to get the value of a variable

    wbg

    EDIT

    I'm a noob....I thought that system.getenv looked like python....It's JAVA
    I got the python version to work, os.getenv("DISPLAY"), this is a quite useful tid bit
    Last edited by wannabegeek; December 12th, 2011 at 03:52 AM.
    Lenovo ThinkPad T400 Core 2 Duo 4GB Ram Mint 13 XFCE
    500 GB spinning iron and 64 GB Crucial SSD in DVD bay.

  6. #6
    Join Date
    Sep 2006
    Beans
    7,699
    Distro
    Lubuntu Development Release

    Re: Environment variables

    Try also .bashrc

  7. #7
    Join Date
    Dec 2007
    Location
    Netherlands
    Beans
    178
    Distro
    Xubuntu 12.04 Precise Pangolin

    Re: Environment variables

    If you want the variable to be present for other users as well, you could also add it to /etc/bash.bashrc (at least that's the file which is used on 10.04).

    If it should be available in a login shell (like when using ssh or direct console access) you could use /etc/profile.

    For a terminal for yourself only the mentioned ~/.bashrc is the right file. And to be complete: ~./.profile is for login shells for yourself only.

    In all cases the syntax would be:
    Code:
    export EJBCA_HOME="/home/user/ejbca"
    LPIC-2 Certified, which doesn't mean I'm a guru.

    All advice is given to the best of my knowledge but without any guarantee that it will work (in your case). (And I don't provide support via Private Messages.)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •