Return the string value of a PSL environment variable.






name of the object whose value is to be returned


The getenv() function returns the string value of variable in the environment of the PSL script. The variable value can be returned from any of the following places:

  • parameter's defined environment variables
  • application's defined environment variables
  • computer's defined environment
  • environment of the PATROL Agent at the start of its execution

The getenv() function searches the environment tables in stated order and returns the value of the first matching variable. The getenv() function returns the NULL string if variable is not defined and sets the PSL errno variable to a nonzero value. If the getenv() function is successful, it returns the value of variable and sets the PSL errno variable to zero. Thus, you can use errno to distinguish an undefined variable from one that is set to the NULL string.

The getenv() function is not implemented by calling the standard C getenv() function.


This PSL example presents a function that tests whether an environment variable exists.

function is_environment_var_defined(name) {
getenv(name); # Throw away return value of getenv
return (errno == 0); # errno is only zero if it is set

Was this page helpful? Yes No Submitting... Thank you