How to set PWD (present working directory) for a Job?

Document ID : KB000015340
Last Modified Date : 14/02/2018
Show Technical Document Details
Question:

How to set PWD (present working directory) for a Job?

When the batch file environment failed the 'PWD' will default to agent installation directory. This could lead to errors as follows.

Example: 

cd D:\CA\CA.RRS\RRS_DailyTrade\Logs 

copy *.log D:\CA\CA.RRS\RRS_DailyTrade\Logs\archive 

copy *.txt D:\CA\CA.RRS\RRS_DailyTrade\Logs\archive 

del *.log,*.txt 

 

All text files in agent directory will be deleted

 

Environment:
Workload Automation AE 11.3.5/11.3.6
Answer:

We can achieve this by two methods

 

At the Agent level

The agentparm.txt has the following parameter 

oscomponent.initialworkingdirectory 

Specifies the default initial working directory for all scripts. Options are as follows: 

SCRIPT 

Sets the path to where the script resides. 

USER 

Sets the path to the home directory of the owner of the script. 

USER_CONT_NOT_AVAIL 

Specifies that the script should run even if a home directory for the user is not defined. 

path 

Specifies the path to the directory in which the script should run. 

 

At the Job level

The envvars attribute specifies environment variables to define the local environment where the script, command, or batch file runs. You can modify existing environment variables or create your own.

envvars: PWD=/usr/scripts/dailyrun

 

Additional Information:

Agent documentation

https://docops.ca.com/ca-workload-automation-agent/11-3/en/reference/ca-wa-agent-for-unix-linux-windows-hp-integrity-nonstop-and-i5-os-reference-information/ca-wa-agent-for-unix-linux-windows-or-i5-os-agent-parameters

Scheduler documentation

https://docops.ca.com/ca-wla-ae-wcc/11-4-2/en/reference/ae-job-information-language/jil-job-definitions/envvars-attribute-specify-a-job-s-environment-variables