Reading Environment Variable

Hi everybody
I'm trying to read an environment variable value, but I don't know how to do it.
Thanks.

Five possibilities:
-Don't use a env var for application values. Use a java property file instead.
-Use System.getenv() on versions before 1.3.
-Use the java command line option '-D' which makes the passed in value available via the system properties.
-Use Runtime.exec() to run a OS specific command that returns the value and parse it.
-Use JNI.

Similar Messages

  • How to read Environment Variable in Java.

    Hi,
    I am trying to read a environment variable $TMP which has a value of /apps/bea/pt847/psoft5/tmp in UNIX.
    I have written the following code and getting Null pointer exception when calling the method logmessage. Any help with reading environment variable is appreciated.
    public static void logMessage(String message) {
           SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
           Date now = new Date();
           Properties p = null;   
           try
              p = getEnvVars("$TMP");
              System.out.println("the current value of TEMP is : " + p.getProperty("$TMP"));
           catch (Throwable e) {
              e.printStackTrace();
           try
           BufferedWriter os = new BufferedWriter(new FileWriter("/tmp/pscas_signon_log.txt", true));
           os.write(formatter.format(now));
           os.write(message);
           os.write("\n");
           os.write("tmp_env = " + p.getProperty("$TMP"));
           os.write("\n");
           os.close();
           catch(IOException _ex) { }
        public static Properties getEnvVars(String env_var) throws Throwable {
           Properties envVars = new Properties();
           Process p = Runtime.getRuntime().exec(env_var);
           BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
           String line = null;
           while( (line = br.readLine()) != null ) {
              int idx = line.indexOf( '=' );
              String key = line.substring( 0, idx );
              String value = line.substring( idx+1 );
              envVars.setProperty( key, value );
              // System.out.println( key + " = " + value );
           return envVars;
        }

    Updated code:
    public static void logMessage(String message) {
           SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ");
           Date now = new Date();
           Properties p = null;   
           try
              p = getEnvVars("$TMP");
              System.out.println("the current value of TEMP is : " + System.getProperty("$TMP"));
           catch (Throwable e) {
              e.printStackTrace();
           try
           BufferedWriter os = new BufferedWriter(new FileWriter("/tmp/pscas_signon_log.txt", true));
           os.write(formatter.format(now));
           os.write(message);
           os.write("\n");
           os.write("tmp_env = " + System.getProperty("$TMP"));
           os.write("\n");
           os.close();
           catch(IOException _ex) { }
        public static Properties getEnvVars(String env_var) throws Throwable {
           Properties envVars = new Properties();
           Process p = Runtime.getRuntime().exec(env_var);
           BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
           String line = null;
           while( (line = br.readLine()) != null ) {
              int idx = line.indexOf( '=' );
              String key = line.substring( 0, idx );
              String value = line.substring( idx+1 );
              envVars.setProperty( key, value );
              // System.out.println( key + " = " + value );
           return envVars;
        }and this is the error message..
    java.io.IOException: $TMP: not found
            at java.lang.UNIXProcess.forkAndExec(Native Method)
            at java.lang.UNIXProcess.<init>(UNIXProcess.java:72)
            at java.lang.Runtime.execInternal(Native Method)
            at java.lang.Runtime.exec(Runtime.java:602)
            at java.lang.Runtime.exec(Runtime.java:461)
            at java.lang.Runtime.exec(Runtime.java:397)
            at java.lang.Runtime.exec(Runtime.java:359)
            at SimpleCasValidator.getEnvVars(SimpleCasValidator.java:108)
            at SimpleCasValidator.logMessage(SimpleCasValidator.java:81)

  • How to read environment variable

    How do I read an environment variable within TS?
    I was thinking of calling getenv("VARIABLE_NAME") except it returns a char * and TS only allows Boolean or Numeric return type.
    I wonder if LV has any function for doing the same thing. 

    With the new ability in TestStand 4.2 to get the standard output from a command line, you can do this with a call executable step.
    Simply call cmd.exe as the executable, and pass it the following expression.  Then all you have to do is set Locals.EnvironmentVariableName to the name of the environment variable you want the value of and define where you want the standard output to be stored.
    "/C \"echo %"+Locals.EnvironmentVariableName+"%\""
    I'm attaching a sequence file that shows this.  The attachment is necessarily saved in TestStand 4.2, since it uses a feature introduced in that version.
    Josh W.
    Certified TestStand Architect
    Formerly blue
    Attachments:
    get env var.seq ‏6 KB

  • Within JBuilder, Reading Environment Variable From a BATCH File

    Hi ppl:
    Following my scenario without JBuilder. I would like to be able to do the same with JBuilder, so that I can run my application from within.
    1. In the DOS window, I run a config.bat file that sets up a whole bunch of environment variables and then calls another script file that sets up another whole bunch to set up environment for a third party API (C++ based).
    2. My application uses native methods to call the third party API which uses the environment variables set in step 1.
    I know how to set the environment varialbes in JBuilder (Project Parameters, VM). However, I don't know how I can call a batch file that does the same. I don't want to set up the third party variables in JBuilder manually, since the script that sets them up checks on a few things to customize the environment.
    I also know how to run a batch file from JBuilder, but that does not set the environment for the application. It seems like the batch file is run in a separate process.
    Any ideas?
    Kamran

    It seems like the batch file is run in a separate process.Yes, it is. That's a design feature of Windows. The environment variables that a process creates are available to any subprocess, but when the process ends, the environment variables vanish. That's because they are part of the process, not global variables as you might wish.
    So that's why your non-JBuilder scenario works; your C++ program is running in a subprocess of the process that defined the environment variables. And your JBuilder scenario doesn't work because the batch file it runs is in a process whose parent process is Windows, not JBuilder.

  • How can I reading environment variables (user variables)

    Hi,
    I hope someone can halp me out:
    In the software that I develop it is neccessary to read some user (environment) variables, such as the temp folder of the current user.
    I know that I can read out some system variables like this:
    String homePath = System.getProperty("user.home");
    But how can I read out some other variables, especially the temp folder of the current user?
    Thanks

    I might have misunderstood you, but I am notlooking
    for the PATH variable. I need the location of
    the
    temp folder of the current user. This should be
    called TEMP or so, but this does not work.Can you deduce from the link he provided, to lookat
    System.getenv(), and find the "TEMP" environment
    variable in what it returns to you?That said, I believe the "temp" folder may be
    provided in one of the normal System properties
    anyway, so you probably don't need to go that route.
    Print all your System.getProperties() values, and see
    if it's in there.Yepp. os.io.temp or something.

  • Read environment variable

    Hi all,
    is there any standard way to read an environment variable (not a java system property) within the SAP J2EE Engine? There is no standard way to so in Java, at least not in Java 1.4.
    Thanks in advance,
    Matthias

    mmmmhhhh
    you are right.
    Maybe in 1.5 System.getenv is "un-deprecated".
    By the way there is a funny solution.
    Execute a OS command like to prompt by CODE and parse the result.
    LOOK HERE!
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4199068

  • Reading Environment variables

    Hi,
    We are having a Flex Application running in Flash player 9.0
    in IE browser. We have a requirement to read the user environment
    variables(Basically client's machine environment variables). Is it
    possible using Flash.
    Please help us

    I do not believe this is possible with just Flex running on
    Flash Player. Flash Player is specifically limited on what
    information it can gather to avoid security issues. The only pieces
    of system information exposed to Flash Player are those gathered
    from the flash.system API:
    http://livedocs.adobe.com/flex/201/langref/index.html

  • Help: reading environment variables?

    Hi! I'm working with node.js in EB3 and am running into a little problem- I have a few environment variables that I want to use (set in .profile and already working in standalone applications). But if I try to read them using process.env.XYZ as usual, they turn up undefined. What am I missing?

    Yes. Checking process.env shows any environment variables that are defined at runtime, as well as PATH, USER, SHELL, etc. Any that I've defined elsewhere don't show up, even if they are exposed as expected to other applications. I've tried exporting from .profile, .bashrc and .bash_profile so far with no changes. Thanks, though- hopefully I'll have an aha moment soon!
    Found a solution via stackexchange: apparently some users have this problem with GUI applications on newer versions of OS X, and the workaround is to set variables in a terminal session and launch the application there. Which defeats the purpose in my case but hope it's useful to someone else!

  • Problem reading environment variable in windows

    Hi,
    When I run this program,
    env1 = "Console";
    env2 = (System.getenv("SESSIONNAME"));
    System.out.print(env1.length() + "/");
    System.out.println(env2.length() + "/");
    System.out.print(env2 + "/");
    System.out.println(System.getenv("SESSIONNAME") + "/");
    if (env1 == env2) System.out.println("identical");
        else  System.out.println("wrong"); I got this output
    7/7/
    Console/Console/
    wrongWhen I type "set" in a Windows cmd box,
    I have SESSIONNAME=Console
    I don't see why env1 and env2 are different.
    Do you know ?
    Thanks,

    O now, I made this mistake already found it myself, but this I did not think about, I
    am sorry to post such a stupid problem !
    and indeed this works, I can continue now.
         if ((System.getenv("SESSIONNAME").equals("Console"))) System.out.println("identical");
                else  System.out.println("wrong"); Thanks jverd !

  • How to read a non-oracle environment variable?

    I have been trying to read a non-oracle environment variable using TOOL_ENV.GETVAR, and have come to understand that it doesn't work. Is there another function that can do what I want? I don't want to hardcode the directory the forms and reports must reside in, but can't find anyway to make this value flexible.
    can anyone help ?
    thx
    adam

    I figured out a way. I put a String in the registry in the oracle home area, and can read it with TOOL_ENV.GETVAR now. It appears that it reads from the registry, not the environment variables. Except for unix apparently, where it reads environment variables.
    adam

  • I am not getting User Environment Variable Value

    Hi Team,
    I have been Trying to recover variables values using an anonym procedure from Windows XP SP3
    I have already executed following procedure.
    BEGIN
    DECLARE
    gf_filelog UTL_FILE.file_type;
    v_file_log VARCHAR2 (1024) := ' ';
    gv_path_log VARCHAR2 (1024) := ' ';
    gv_path_log2 VARCHAR2 (1024) := ' ';
    gv_file_log VARCHAR2 (1024) := ' ';
    BEGIN
    DBMS_OUTPUT.put_line ( 'obteniendo valores of vars: '
    || gv_path_log
    || ' '
    || gv_file_log
    DBMS_SYSTEM.get_env ('ORACLE_HOME', gv_path_log);
    DBMS_SYSTEM.get_env ('PATH_MODULO', gv_path_log2);
    DBMS_SYSTEM.get_env ('FILELOG', v_file_log);
    DBMS_OUTPUT.put_line ( 'valores vars ORACLE_HOME: '
    || gv_path_log
    || 'PATH_MODULO:'
    || gv_path_log2
                   || ' FILELOG:'
                   || v_file_log
    gv_file_log :=
    v_file_log || TO_CHAR (SYSDATE, 'yyyymmddHH24MISS')
    || '.log';
    DBMS_OUTPUT.put_line ( 'Nombre de Archivo creado'
    || gv_path_log
    || ' '
    || gv_file_log
    gf_filelog := UTL_FILE.fopen (gv_path_log, gv_file_log, 'w');
    DBMS_OUTPUT.put_line ('Archivo creado' || gv_path_log || ' '
    || gv_file_log
    UTL_FILE.put_line (gf_filelog,
    || TO_CHAR (SYSDATE, 'HH24:MI:SSSSS')
    || ']--> '
    || 'Prueba de escritura'
    || gv_path_log
    || ' '
    || v_file_log
    UTL_FILE.fflush (gf_filelog);
    UTL_FILE.fclose (gf_filelog);
    EXCEPTION
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ( '[reporta_log]Error en :'
    || SQLCODE
    || ' - '
    || SQLERRM
    raise_application_error (-20000,
    '[reporta_log]Error en :'
    || SQLCODE
    || ' - '
    || SQLERRM
    END;
    END;
    I show you data result after procedure was excecuted.
    obteniendo valores of vars:
    valores vars ORACLE_HOME: E:\oracle\product\10.2.0\db_1PATH_MODULO: FILELOG:
    Nombre de Archivo creadoE:\oracle\product\10.2.0\db_1 20111122171625.log
    [reporta_log]Error en :-29280 - ORA-29280: invalid directory path
    BEGIN
    ERROR at line 1:
    ORA-20000: [reporta_log]Error en :-29280 - ORA-29280: invalid directory path
    ORA-06512: at line 55
    I see that only ORACLE_HOME variable value was got, question is why, of course, variable values are already defined as user variables.
    Variables PATH_MODULO and FILELOG was defined using windows maintenance variable method, that is :
    1.- settings
    2.- system
    3.- advanced options
    4.- environment variables
    Here my oracle version
    SQL> select version from v$instance;
    VERSION
    10.2.0.1.0
    SQL>
    Is this an Oracle Issue or variables would be defined in another way?
    ORACLE_HOME VARIABLE was created when oracle engine was installed.
    I have got same result after computer was restart.
    I appreciate wathever clue.

    Ok, that is , I only can read environment variables values, but not variables values at user profile. It happends in unix environment too. So I tried to use another instruction sequence in order to read user variables values.
    Regards

  • How to use windows environment variable "%appdata%" in TEXT_IO built-in

    Hello Sir/Madam,
    I'm currently using TEXT_IO built-in package to write data file user's "C" drive in Oracle Forms 6i on Windows XP OS. We are in the process of upgrading the OS to Windows7. This new version does not allow to write to "C" or "D" drive. I was wondering how I can use windows environment variable "%appdata%" in this built-in to write the data file to user's AppData folder?
    I would appreciate your help.
    Regards,
    Vani Sonti

    You are obviously not familiar with the architecture of webforms. See here http://www.oracle.com/technetwork/developer-tools/forms/275632-133265.pdf
    I guess you are running your forms locally, so the forms server and the client run on the very same machine. This won't be the case once you run in production, as you will have an application server and clients connecting to the server.
    text_io, tool_env and all the forms built ins will be executed on the machine the forms runtime runs on, and in a 3 tier architecture this is the application server, not the client as the real client will run just a java applet which actually just does what the forms runtime on the server tells it to do (or passes client side events like mouse clicks to the forms runtime on the server).
    A very simple explanation for the architecture would be that the whole GUI part has been ripped off the forms runtime and put into a java applet; the logic part (the old-fashioned forms runtime) where the whole Forms PL/SQL code is executed communicates with the GUI part (which is implemented as a java applet) via HTTP, so there is no need to have both running on the very same machine.
    So if you are writing a file with text_io on c:\dummy.txt this file will be generated on the application server machine as it is executed where the forms runtime runs. If you read environment variables with tool_env.getvar you will get the environment variable from the application server machine.
    If you need those variables from your application server then those built-in packages are what you need, but if you need the real client variables there is no way around java in webforms 6i. But the beans should be simple enough to have them written within no time ;)
    cheers

  • How to get system Environment variable?

    How to get system Environment variable without using jni?
    just like "JAVA_HOME" or "PATH"...
    Any reply is help to me!! :-)

    Thx for your reply...
    I get it!!!
    Read environment variables from an application
    Start the JVM with the "-D" switch to pass properties to the application and read them with the System.getProperty() method. SET myvar=Hello world
    SET myothervar=nothing
    java -Dmyvar="%myvar%" -Dmyothervar="%myothervar%" myClass
    then in myClass String myvar = System.getProperty("myvar");
    String myothervar = System.getProperty("myothervar");
    This is useful when using a JAVA program as a CGI.
    (DOS bat file acting as a CGI) java -DREQUEST_METHOD="%REQUEST_METHOD%"
    -DQUERY_STRING="%QUERY_STRING%"
    javaCGI
    If you don't know in advance, the name of the variable to be passed to the JVM, then there is no 100% Java way to retrieve them.
    NOTE: JDK1.5 provides a way to achieve this, see this HowTo.
    One approach (not the easiest one), is to use a JNI call to fetch the variables, see this HowTo.
    A more low-tech way, is to launch the appropriate call to the operating system and capture the output. The following snippet puts all environment variables in a Properties class and display the value the TEMP variable. import java.io.*;
    import java.util.*;
    public class ReadEnv {
    public static Properties getEnvVars() throws Throwable {
    Process p = null;
    Properties envVars = new Properties();
    Runtime r = Runtime.getRuntime();
    String OS = System.getProperty("os.name").toLowerCase();
    // System.out.println(OS);
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set" );
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1 )
    || (OS.indexOf("windows xp") > -1) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set" );
    else {
    // our last hope, we assume Unix (thanks to H. Ware for the fix)
    p = r.exec( "env" );
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String line;
    while( (line = br.readLine()) != null ) {
    int idx = line.indexOf( '=' );
    String key = line.substring( 0, idx );
    String value = line.substring( idx+1 );
    envVars.setProperty( key, value );
    // System.out.println( key + " = " + value );
    return envVars;
    public static void main(String args[]) {
    try {
    Properties p = ReadEnv.getEnvVars();
    System.out.println("the current value of TEMP is : " +
    p.getProperty("TEMP"));
    catch (Throwable e) {
    e.printStackTrace();
    Thanks to W.Rijnders for the W2K fix.
    An update from Van Ly :
    I found that, on Windows 2003 server, the property value for "os.name" is actually "windows 2003." So either that has to be added to the bunch of tests or just relax the comparison strings a bit: else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1 )
    || (OS.indexOf("windows 2003") > -1 ) // works but is quite specific to 2003
    || (OS.indexOf("windows xp") > -1) ) {
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 20") > -1 ) // probably is better since no other OS would return "windows" anyway
    || (OS.indexOf("windows xp") > -1) ) {
    I started with "windows 200" but thought "what the hell" and made it "windows 20" to lengthen its longivity. You could push it further and use "windows 2," I suppose. The only thing to watch out for is to not overlap with "windows 9."
    On Windows, pre-JDK 1.2 JVM has trouble reading the Output stream directly from the SET command, it never returns. Here 2 ways to bypass this behaviour.
    First, instead of calling directly the SET command, we use a BAT file, after the SET command we print a known string. Then, in Java, when we read this known string, we exit from loop. [env.bat]
    @set
    @echo **end
    [java]
    if (OS.indexOf("windows") > -1) {
    p = r.exec( "env.bat" );
    while( (line = br.readLine()) != null ) {
    if (line.indexOf("**end")>-1) break;
    int idx = line.indexOf( '=' );
    String key = line.substring( 0, idx );
    String value = line.substring( idx+1 );
    hash.put( key, value );
    System.out.println( key + " = " + value );
    The other solution is to send the result of the SET command to file and then read the file from Java. ...
    if (OS.indexOf("windows 9") > -1) {
    p = r.exec( "command.com /c set > envvar.txt" );
    else if ( (OS.indexOf("nt") > -1)
    || (OS.indexOf("windows 2000") > -1
    || (OS.indexOf("windows xp") > -1) ) {
    // thanks to JuanFran for the xp fix!
    p = r.exec( "cmd.exe /c set > envvar.txt" );
    // then read back the file
    Properties p = new Properties();
    p.load(new FileInputStream("envvar.txt"));
    Thanks to JP Daviau
    // UNIX
    public Properties getEnvironment() throws java.io.IOException {
    Properties env = new Properties();
    env.load(Runtime.getRuntime().exec("env").getInputStream());
    return env;
    Properties env = getEnvironment();
    String myEnvVar = env.get("MYENV_VAR");
    To read only one variable : // NT version , adaptation for other OS is left as an exercise...
    Process p = Runtime.getRuntime().exec("cmd.exe /c echo %MYVAR%");
    BufferedReader br = new BufferedReader
    ( new InputStreamReader( p.getInputStream() ) );
    String myvar = br.readLine();
    System.out.println(myvar);
    Java's System properties contains some useful informations about the environment, for example, the TEMP and PATH environment variables (on Windows). public class ShowSome {
    public static void main(String args[]){
    System.out.println("TEMP : " + System.getProperty("java.io.tmpdir"));
    System.out.println("PATH : " + System.getProperty("java.library.path"));
    System.out.println("CLASSPATH : " + System.getProperty("java.class.path"));
    System.out.println("SYSTEM DIR : " +
    System.getProperty("user.home")); // ex. c:\windows on Win9x system
    System.out.println("CURRENT DIR: " + System.getProperty("user.dir"));
    Here some tips from H. Ware about the PATH on different OS.
    PATH is not quite the same as library path. In unixes, they are completely different---the libraries typically have their own directories. System.out.println("the current value of PATH is: {" +
    p.getProperty("PATH")+"}");
    System.out.println("LIBPATH: {" +
    System.getProperty("java.library.path")+"}");
    gives the current value of PATH is:
    {/home/hware/bin:/usr/local/bin:/usr/xpg4/bin:/opt/SUNWspro/bin:/usr/ccs/bin:
    /usr/ucb:/bin:/usr/bin:/home/hware/linux-bin:/usr/openwin/bin/:/usr/games/:
    /usr/local/games:/usr/ccs/lib/:/usr/new:/usr/sbin/:/sbin/:/usr/hosts/:
    /usr/openwin/lib:/usr/X11/bin:/usr/bin/X11/:/usr/local/bin/X11:
    /usr/bin/pbmplus:/usr/etc/:/usr/dt/bin/:/usr/lib:/usr/lib/lp/postscript:
    /usr/lib/nis:/usr/share/bin:/usr/share/bin/X11:
    /home/hware/work/cdk/main/cdk/../bin:/home/hware/work/cdk/main/cdk/bin:.}
    LIBPATH:
    {/usr/lib/j2re1.3/lib/i386:/usr/lib/j2re1.3/lib/i386/native_threads:
    /usr/lib/j2re1.3/lib/i386/client:/usr/lib/j2sdk1.3/lib/i386:/usr/lib:/lib}
    on my linux workstation. (java added all those execpt /lib and /usr/lib). But these two lines aren't the same on window either:
    This system is windows nt the current value of PATH is:
    {d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;c:\depot\cdk\main\cdk\bin;c:\depot\
    cdk\main\cdk\..\bin;d:\OrbixWeb3.2\bin;D:\Program
    Files\IBM\GSK\lib;H:\pvcs65\VM\win32\bin;c:\cygnus
    \cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;D:\orant\bin;C:\WINNT\system32;C:\WINNT;
    C:\Program Files\Dell\OpenManage\Resolution Assistant\Common\bin;
    d:\Program Files\Symantec\pcAnywhere;
    C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}
    LIBPATH:
    {D:\jdk1.3\bin;.;C:\WINNT\System32;C:\WINNT;d:\OrbixWeb3.2\bin;D:\jdk1.3\bin;
    c:\depot\cdk\main\cdk\bin;c:\depot\cdk\main\cdk\..\bin;
    d:\OrbixWeb3.2\bin;D:\Program Files\IBM\GSK\lib;
    H:\pvcs65\VM\win32\bin;c:\cygnus\cygwin-b20\H-i586-cygwin32\bin;d:\cfn\bin;
    D:\orant\bin;C:\WINNT\system32;
    C:\WINNT;C:\Program Files\Dell\OpenManage\ResolutionAssistant\Common\bin;
    d:\Program Files\Symantec\pcAnywhere;
    C:\Program Files\Executive Software\DiskeeperServer\;C:\Program Files\Perforce}

  • How to access environment variables from Oracle Forms

    Hi,
    Any idea how to use the Environment variables from Oracle Forms.
    My basic problem is that from Oracle form I am calling Batch file which calls excel file with a macro.
    So i want to check whether the macro was successful or not.
    So in my batch file i will set %errorlevel% which I should be able to read from Oracle Forms.
    I am able to read the registry from oracle forms, so is there anyway to read environment variable as well?
    Thanks!
    Avinash.

    Hello,
    Use the TOOL_ENV.Getvar() built-in
    Francois

  • Environment variables from ~/.MacOSX/environment.plist not read?

    Hello,
    I repost this from "Mac OS X 10.5 Leopard > Account and Login" since it was advised to me overthere. Sorry if your already read this one before.
    I have a problem defining environment variables that should be visible to all my user processes, not only Terminal. According to the Apple documentation, I need to create a file ~/.MacOSX/environment.plist and define my variables in there.
    Below you can see the exact paths and file name, together with the contents of the plist file:
    <pre>
    /Users/ringods/.MacOSX
    AtrisoBook:.MacOSX ringods$ ls -l
    total 8
    -rw-r--r--@ 1 ringods staff 313 Sep 29 15:35 environment.plist
    AtrisoBook:.MacOSX ringods$ cat environment.plist
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>ANT_HOME</key>
    <string>/opt/local/share/java/apache-ant</string>
    </dict>
    </plist>
    </pre>
    I then tried a logout/login sequence, but no ANT_HOME environment variable was defined. Even after completely rebooting, the environment variable was still not defined. I checked in a Terminal window using any of the following 3 commands:
    <pre>
    env
    export
    set
    </pre>
    This is on a MacBook Pro running 10.5.5. Am I missing something here? Does anyone know how to resolve this?
    Ringo

    I'm currently experiencing the same issue.
    I find however, if I take out the underscore from the name it works. At least the times I've tried.
    There is a post about using launchd.conf for configuring environment variables, but I couldn't get that to work either.

Maybe you are looking for