Previous Topic: ENGINEID Statement—Specify an Engine IDNext Topic: EVENT Statement—Specify the SAP Event to Monitor or Trigger


ENVAR Statement—Pass Environment Variables

The ENVAR statement passes environment variables to a batch file, script, command, or program.

Supported Job Types

This statement is optional for the following job types:

Syntax

This statement has the following format:

ENVAR name=value |
      EWA_ENV_SRC_N=path |
      EWAGLOBALPROFILE=path | 
      HOME=path | PWD=path |
      STDIN=keyboard|path | STDOUT=spoolfile|path | STDERR=spoolfile|path
name=value

Specifies the name of the environment variable and the value assigned to the variable.

Note: If the resulting value requires spaces, such as a date, enclose the value in double quotes in the ENVAR statement.

EWA_ENV_SRC_N=path

Specifies the full path of the file or script to be sourced for environment variables, where N is a positive integer. You can use this variable in UNIX and Windows jobs to pass environment variables set in a file or script prior to job execution.

UNIX:

Windows: The file to be sourced must contain name=value pairs.

EWAGLOBALPROFILE=path

Specifies the full path of the script to be sourced for environment variables. You can use this variable in UNIX jobs to pass environment variables set in a script prior to job execution.

Notes:

HOME=path

Specifies the fully-qualified name of the home directory to switch to before running the batch file, script, command, or program. The HOME operand applies to all job definitions except for UNIX-type jobs and Micro Focus jobs. Alternatively, you can use the SCRIPT option in the oscomponent.initialworkingdirectory parameter in the agent's agentparm.txt file.

Note: If HOME is not specified, the command or script runs in the initial working directory as specified by the oscomponent.initialworkingdirectory parameter in the agentparm.txt file. For more information about oscomponent.initialworkingdirectory, see the CA Workload Automation Agent for UNIX, Linux, or Windows User Guide.

PWD=path

Specifies the name of the Present Working Directory (PWD) to switch to before running a UNIX command or script. The PWD operand applies to UNIX job definitions only.

Note: If the PWD is not specified, the command or script runs in the initial working directory as specified by the oscomponent.initialworkingdirectory parameter in the agentparm.txt file. For more information about oscomponent.initialworkingdirectory, see the CA Workload Automation Agent for UNIX, Linux, or Windows User Guide.

STDIN=keyboard|path

Specifies the full path of an alternative standard input stream. If you do not specify the STDIN operand, by default the standard input stream is the keyboard.

STDOUT=spoolfile|path

Specifies the full path of an alternative standard output stream. If you do not specify the STDOUT operand, by default the standard output stream goes to the spool file.

The STDOUT file name displays when you list the workload object with the LISTAPPL or APPLJOB command. The STDOUT file name can be different from what was specified in STDOUT=. In the following example, if the environment variable AGENTPATH equaled '/root/home/2, the file name would resolve to StdOut=/root/home/2/stdout.txt in the output of the workload object.

ENVAR STDOUT=$AGENTPATH/stdout.txt

For HP Integrity NonStop, STDOUT specifies the job output file location. New output overwrites existing output unless you add the >> prefix before the file name. The >> prefix causes the adding of new output to the current output file. In the following example, any output that the job generates is added to the end of the $TEST.Test1.Output1 file.

ENVAR STDOUT=>>$TEST.Test1.Output1

STDOUT is applicable only for Windows NT, all UNIX agents, and HP Integrity NonStop.

STDERR=spoolfile|path

Specifies the full path of an alternative standard error output stream. If you do not specify the STDERR operand, by default the standard error output stream goes to the spool file.

The STDERR file name displays when you list the workload object with the LISTAPPL or APPLJOB command.

The STDERR file name can be different from what was specified in STDERR=. In the following example, if the environment variable AGENTPATH equaled '/root/home/2', the file name would resolve to StdErr=/root/home/2/stderr.txt in the output of the workload object.

ENVAR STDERR=$AGENTPATH/stderr.txt

For HP Integrity NonStop, STDERR specifies the job error file location. New errors overwrite existing errors unless you add the >>prefix before the file name. The >> prefix causes the adding of new errors to the current error file. In the following example, any errors that the job generates are added to the end of the $TEST.Test1.Error1 file.

ENVAR STDERR=>>$TEST.Test1.Error1

STDERR is applicable only for Windows NT, all UNIX agents, and HP Integrity NonStop. STDERR is only available for compiled binary commands. TACL scripts do not support STDERR streams.

Notes:

Example: Pass Windows Environment Variables to a Batch File

This example includes three ENVAR statements that pass environment variables to a Windows batch file and a fourth ENVAR statement that defines the home directory:

CMDNAME c:\payroll\command1
AGENT NT_NY
ENVAR A=B
ENVAR C='X Y'
ENVAR E=pay
ENVAR HOME=c:\export\u1

In this example, the command command1 can reference these variables:

Environment Variable

Value Passed

A

B

C

'X Y'

E

pay

HOME

c:\export\u1

Example: Pass UNIX Environment Variables to a Script

This example includes two ENVAR statements that pass environment variables to a script and a third ENVAR statement that defines the Present Working Directory (PWD). The parameter "user 1" is enclosed with double quotation marks because it contains a space.

SCRIPTNAME /home/scripts/pay
AGENT UNIX_NY
ENVAR NAME="user 1"
ENVAR JOB=PAYROLL
ENVAR PWD=/usr/scripts/dailyrun

In this example, the pay script can reference these variables:

Environment Variable

Value Passed

NAME

user 1

JOB

PAYROLL

PWD

/usr/scripts/dailyrun

Example: Source Windows Environment Variables from a File

This example uses the EWA_ENV_SRC_1 environment variable to source environment variables from a file. Before the test_var3 command file runs, the test_var4.txt file is sourced and the variables in the file are resolved.

AGENT WINAGT
CMDNAME %scripts\test_var3
ENVAR EWA_ENV_SRC_1=c:\qatest\env\test_var4.txt

The test_var4.txt file contains the following:

AD_TOP=C:\oracle\OA12\apps\apps_st\appl\ad\12.0.0
ADJREOPTS=-ms128m -mx256m -Xrs

NLS_LANG=American_America.WE8MSWIN1252

ZX_TOP=C:\oracle\OA12\apps\apps_st\appl\zx\12.0.0

TEST1=test1
TEST2=test two
TEST3= test 3

Example: Source UNIX Environment Variables from a Script Using EWA_ENV_SRC_N

This example uses the EWA_ENV_SRC_1 environment variable to source environment variables from a script. The agent runs as root and the oscomponent.loginshell agent parameter is set to true. Before the test_var3 script runs, the test_var_ewal.txt script is sourced and the variables in the file are resolved.

AGENT UNIXAGT
SCRIPTNAME %scripts/test_var3
ENVAR EWA_ENV_SRC_1=%var_dir/test_var_ewa1.txt

The test_var_ewal.txt script contains the following:

#!/bin/sh
AD_TOP=/oracle/OA12/apps/apps_st/appl/ad/12.0.0
export AD_TOP
ADJREOPTS="-ms128m -mx256m -Xrs"
export ADJREOPTS
NLS_LANG=American_America.WE8MSWIN1252
export NLS_LANG
ZX_TOP=/oracle/OA12/apps/apps_st/appl/zx/12.0.0
export ZX_TOP
TEST1=test1
export TEST1
TEST2="test two"
export TEST2
TEST3=" test 3 "
export TEST3

Example: Source UNIX Environment Variables from a Script Using EWAGLOBALPROFILE

This example uses the EWAGLOBALPROFILE environment variable to source environment variables from a script. The agent runs as root and the oscomponent.loginshell agent parameter is set to true. Before the echo command runs, the test_var_ewa_global.txt script is sourced and the variables in the file are resolved.

AGENT UNIXAGT
USER qatest
CMDNAME /usr/bin/echo
ARGS '$TEST_EWA_GLOBAL > %data/variable_test_EWA_global.txt'
ENVAR EWAGLOBALPROFILE=%var_dir/test_var_ewa_global.txt

The test_var_ewa_global.txt script contains the following:

#!/bin/ksh
TEST_EWA_GLOBAL="test ewa global"
export TEST_EWA_GLOBAL

Example: Set HP Integrity NonStop Environment Variables

In this example, the ENVAR statements do the following: