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

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 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

  • How to read url variable javascript problem

    How to read the variable of latitude 1.22 and longitude 103.56.
    This is my website: 127.0.0.1/1/map2.htm?latitude=1.22&longitude=103.56
    function getUrl_Map()
              //Get the variables in the URL
         var vars = [], hash;
              var latitude = getUrlVars()["latitude"];
              //To get the second parameter
              var longitude= getUrlVars()["longitude"];
         var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
         alert('DEBUG: hashes= ' + hashes);
              // read the file http://127.0.0.1/1/map2.htm
              // read the file http://127.0.0.1/1/map2.htm? -->hashes
         for(var i = 0; i < hashes.length; i++)
         hash = hashes.split('=');
                   //alert('DEBUG: i= ' + i);
                   //i=0
                   alert('DEBUG: i= ' + i + 'hash = ' + hash );
         vars.push(hash [0]);
         vars[hash [0]] = hash [1];

    by the way you know that 127.0.0.1 is the address you use to get to your own computer right? It's the loopback address. so posting it doesn't really help anybody see the page, if that was what you were hoping.

  • How to read a variable within a VC code.  I am using BADI based VC code.

    How to read a variable within a VC code.  I am using BADI based VC code.
    Lets say I have a variable for a fiscal period that holds cumulative month.
    If user enters 03/2014 in that variable, it will have month starting from Jan till March.
    Within VC code I would like to read the last month which is
    03/2014 and based on this month I would like to do some calculation on all the records using the last month.
    Since VC code runs for one record at a time and there is no way I can store this value.
    Is there a way to go about it....any suggestions would be of great help.
    Thanks.

    Any suggestions would be highly appreciated.
    Thanks!

  • How to set environment variables in WL ?

    Hi,
    How to set environment variables in WL ?
    Thanks,
    Srivi

    Hi,
    You can set the environmet variable in Weblogic by using the below commands
    setWLSEnv.cmd/sh ==>Set the CLASSPATH to include the WebLogic Server classes.
    Overview of WebLogic Server Domains
    or you can use to set the Environment variable along with domain specific varables using the SetDomainEnv.cmd
    To run SetDomainEnv.sh in Linux please use
    . ./setDomainEnv.sh it require two dots (Dont miss it )
    http://docs.oracle.com/cd/E28280_01/web.1111/e13749/weblogicserver.htm#ADMRF205
    Hope it helps

  • How to set environment variable ORACLE_HOME ?

    Hi
    I trying to install SAP Solution manager 4.0 SR3:
    OS: Linux RHEL4u4
    DB: Oracle
    SAPinst now stops the installation.
    To proceed with the installation, install the Oracle database as follows:
    1.Log in as user orassm.
    2.Set the DISPLAY variable.
    3.Change to directory /oracle/stage/102_32/database/SAP.
    4.Start './RUNINSTALLER'.
    After you installed the Oracle database software, proceed with the database instance
    installation by choosing 'OK' in this dialog box.
    ./RUNINSTALLER
    oracle_stage is not set (OK)
    oracle_base is not set (OK)
    oracle_home is not set (OK)
    oracle_sid is not set (OK)
    oracle_home_name is not set (OK)
    oracle_inst_group is not set (OK)
    from_location is not set (OK)
    tmp_netca_file is not set (OK)
    tmp_dbca_file is not set (OK)
    Working in /oracle/stage/102_32/database/SAP ...
    The environment variable ORACLE_HOME is not set! abort ...
    How to set environment variable ORACLE_HOME ?
    Regards
    Eric

    i
    Switch shell to bash:
    orassm:x:502:503:SAP Database Administrator:/oracle/SSM:/bin/bash
    [root@csp-p-sm00 ~]# su - orassm
    [orassm@csp-p-sm00 ~]$
    But when try to run ./RUNINSTALL
    [orassm@csp-p-sm00 SAP]$ ./RUNINSTALLER
    oracle_stage is not set (OK)
    oracle_base is not set (OK)
    oracle_home is not set (OK)
    oracle_sid is not set (OK)
    oracle_home_name is not set (OK)
    oracle_inst_group is not set (OK)
    from_location is not set (OK)
    tmp_netca_file is not set (OK)
    tmp_dbca_file is not set (OK)
    Working in /oracle/stage/102_32/database/SAP ...
    The environment variable ORACLE_HOME is not set! abort ...
    Additionaly I've post csh.cshrc and csh.login
    /etc/cshrc
    csh configuration for all shell invocations.
    by default, we want this to get set.
    Even for non-interactive, non-login shells.
    [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]
    if $status then
            umask 022
    else
            umask 002
    endif
    if ($?prompt) then
      if ($?tcsh) then
        set prompt='[%n@%m %c]$ '
      else
        set prompt=\[`id -nu`@`hostname -s`\]\$\
      endif
    endif
    if ( $?tcsh ) then
            bindkey "^[[3~" delete-char
    endif
    setenv MAIL "/var/spool/mail/$USER"
    limit coredumpsize 0
    if ( -d /etc/profile.d ) then
            set nonomatch
            foreach i ( /etc/profile.d/*.csh )
                    if ( -r $i ) then
                            source $i
                    endif
            end
            unset i nonomatch
    endif
    /etc/csh.login
    System wide environment and startup programs, for login setup
    if ($?PATH) then
            if ( "$" !~ /usr/X11R6/bin ) then
                    setenv PATH "$:/usr/X11R6/bin"
            endif
    else
            if ( $uid == 0 ) then
                    setenv PATH "/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
            else
                    setenv PATH "/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin"
            endif
    endif
    setenv HOSTNAME `/bin/hostname`
    set history=1000
    if ( ! -f $HOME/.inputrc ) then
            setenv INPUTRC /etc/inputrc
    endif
    Regards
    Eric

  • 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.

  • How to set environment variable?

    Hi,
    I just succeeded starting up an external executable by using nativeprocess.
    Now I have to set the portnumber as an environment variable.
    After setting this portnumber, I can send queries to the executable.
    But I don't now how to set this environment variable.
    You can see my try in bold:
    Starting the executable (an extract of the code):
    public var portnumber;
    file = file.resolvePath("C:\\Program Files\\CM Synergy 6.3\\bin\\start_dbase.exe");    #start executable
    process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, getportnumber);    #get portnumber as output of the executable
    The next step is to define the variable portnumber:
    file = file.resolvePath("C:\\WINDOWS\\system32\\cmd.exe");
    processArgs[0] = "/C";
    processArgs[1] = "set";
    processArgs[2] = "portnumber=";
    processArgs[3] = portnumber;
    When I try to print out all environment variables, portnumber is not in:
    file = file.resolvePath("C:\\WINDOWS\\system32\\cmd.exe");
    processArgs[0] = "/C";
    processArgs[1] = "set";
    If I replace the last executable with my real command (running the query), the executable is giving the error that my portnumber is not set.
    Is it possible? I have also tried it with setx.exe. Even running a python script where I set os.environ is not working.
    I have the feeling that the command is executed but that the variable is not remembered for the next executable.

    Hello Martin,
    Thanks for your input. I have tried what you suggested but it didn't work. I will post my source code. Perhaps I'm doing something wrong. After setting my variable portnumber, I would normally run a query. Instead of running the query, I'm writing out the environment variables. Unfortunately, portnumber is not in the list . I also tried using "setx" insetad of "cmd.exe set" but without any difference.
        public var portnumber;
        public function run_query():void
            var file:File = new File("C:/WINDOWS/System32/cmd.exe");
            var si:NativeProcessStartupInfo = new NativeProcessStartupInfo();
            si.executable = file;
            var processArgs:Vector.<String> = new Vector.<String>();
            processArgs[0] = "/C";
            processArgs[1] = "set";
            nativeProcessStartupInfo.arguments = processArgs;
            var process:NativeProcess = new NativeProcess();
            process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
            process.start(si);
        public function set_portnumber():void
            var file:File = new File("C:/WINDOWS/System32/cmd.exe");
            var si:NativeProcessStartupInfo = new NativeProcessStartupInfo();
            si.executable = file;
            var process:NativeProcess = new NativeProcess();
            process.start(si);
            process.standardInput.writeUTF("set portnumber="+portnumber+"\n")
            setTimeout(run_query, 1000);
        public function onOutputData(event:ProgressEvent):void
            var process:NativeProcess = event.target as NativeProcess;
            textReceived.text += process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable) + "\n";

  • How to pass environment variables to adf application?

    Hi,
    I Created form function with this settings to open my adf application:
    Type : SSWA plsql function
    Maint Mode = None
    Context : Resp
    Web HTML : test.jsp
    Web host: 192.168.1.30:8890
    This works fine. But how can I pass environment variables as parameters?
    I like to pass username and org_id.
    Thanks in advance

    KdeGraaf,
    Sounds real interestign what you are saying. But I don't know what you mean with:"the application server name appended till html folder($COMMON_TOP/html) "
    Basically if u make a SSWA jsp function with only jsp name say A.jsp.At runtime the url is automatically converted tohttp://<application server>:<port number>/OA_HTML/A.jsp
    By the way $COMMON_TOP/html folder is the location for all jsps' in EBS.
    Where can I find some information about making a OAF page wrapper? Because I have totaly now experience with OAF.
    Make a OAF page, say page A, in process request of page get all the context data say, responsibility, org etc, and set it in http session.Then redirect the flow to ur ADF application page. If ur new and have no knowledge how do we build a page in OAF, u can download OAF developers guide from metalink. Search old threads u would get get the metalink id.--Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • 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.

  • How to add environment variable programmatically??

    Hi all,
    I want to add TOMCAT_HOME environment variable programmatically. How can I do this?
    Is there any dos command to set an environment persistently?
    Pls help guys...
    Thanks in advance
    Mithunk

    The way environmental variables work is that they are passed to newly created tasks by the task that creates them. So, for example, when a command shell calls Java it passes a copy if it's current environmental variables, and if Java calls Runtime.exec it can override the set it passes on.
    The comands within a shell that set environmental variables can do so because they are part of the command shell, not separate programs run by it.
    In short a program run by a shell can't alter the environmental variables belonging to the shell. They move only from the calling task to the called.

  • 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 to use Environment variables in Context Settings

    I need to set some Preferences using a Context, and in the value of the preference I need to use a path which may change depending on the OS.
    I need to use environment variables or java variables to create the relative path for the value.
    Is possible to access env variables from a Context Setting?
    Just to give an example, I'm trying to set the M2_REPO variable in the classpath settings in the preferences menu.
    to user.home + /.m2/repository
    How can I access the user.home from there?

    Hi Matias,
    Sure, you can use substitute-variables command for this purpose.
    See the example below:
    concat [substitute-variables "${system_property:user.home}" | str] "/.m2/repository"]
    Kind regards,
    Ulyana.

  • How to look Environment Variable

    Hi All:
    Can any one let me know how can I find environmental variable??
    For example I am working in Server (XMD, XMP,XMS)
    D=development
    P=production
    S=Staging
    Now I need to map this filed to target filed<system>.
    So how can I get this variable ? Suppose I receive "XMD" then cheking last char "D" or "P" or "S" I can map Development, Production or Staging.
    -For this I need to write a java code(to get Environment Variable)
    or I can achive it in Graphical Mapping tool itself.
    Max points for the best answer
    Regards,
    Farooq.
    Regards,
    Farooq.

    here is more details :
    <b>source mesg:</b>
    name
    id
    address
    <b>target id</b>
    name
    id
    address
    en_variable
    I have one fixValues table
    XMD - Developemt
    XMP - Production
    XMS - Staging.
    so before mapping this I need to chek what is  my environment variable.
    so according to that I can Map the respective field
    bottom line how can I get a SID so that I can map it to target.
    Regards.
    Farooq.

Maybe you are looking for

  • Oracle 10g JDev IDE 9.0.5.2 Null Pointer Exception while debugging

    Hi, In windows XP m/c, I am facing following Null Pointer Exception while debugging basic Java application through 10g JDev 9.0.5.2, and it failed in debugging that application... May I know, How to get it out of this problem..., am suspecting Is it

  • Trying to find unused tables by views,function, and proc?

    I come up with lists of unused table through given script SELECT SCHEMA_NAME(t.schema_id) as SchemaName, t.name as TableName FROM   sys.tables t WHERE  is_ms_shipped = 0 AND NOT EXISTS (SELECT FROM   sys.sql_expression_dependencies d WHERE  d.referen

  • Running Adobe Document Services

    Hello, We are looking at a project that will require the use of Adobe Interactive forms.  In looking at the requirements for this, I see that we need to run the Adobe Document Services (ADS).  The ADS runs on the SAP Java AS.  In reviewing the SAP Pr

  • Having trouble with the highlights

    I have Samsung Galaxy S3 with Android 4:3 I am having trouble with the highlight feature. When I highlight a word or a sentence Adobe Reader highlights it without a problem yet I cannot see all the highlighted parts of the pdf file as a list. Thus I

  • Deleting preinstalled Apps

    How do I delete preinstalled apps? I dont want the preinstalled email App since it's designed for very low amounts of emails and not suited for 150-200 mails a day. Also I'd like to get rid of the gaming center and replace the buggy pre installed cam