Previous Topic: Set a UNIX Job's Process PriorityNext Topic: Modify Resource Limits


Running a Script Under a Specific User's Account

Using the agent, there are two ways to run a command or script under a specific user's account:

Note: When the agent is started as root and there is no USER statement in the job definition, by default the agent runs the script as the owner of the script. For more information about this default, see the definition of the parameter oscomponent.noswitchsuid in the CA Workload Automation Agent for UNIX, Linux, or Windows Implementation Guide.

If the shell is specified in the first line of the script and its path matches the path defined in the oscomponent.validshell parameter, you do not have to use the SHELL statement to define the shell that you want the agent to use. For example, you can run a script using the environment defined in a specific user's account.

Example: Run a Script Under a Specific User Account

In this example, if the first line of the script is #!/bin/ksh and the path /bin/ksh is defined using the oscomponent.validshell parameter, you can use the USER statement to run the script under a specific user account, as follows:

AGENT SUN30RD
SCRIPTNAME /home/guest/bin/cmd1.ksh
USER guest

In this example, the agent runs the cmd1.ksh Korn script using the environment defined in either the $HOME/.login file or the
$HOME/.profile file, depending on which login shell is defined for user guest:

The login shell for user guest does not have to be the Korn shell. For example, the agent can pick up the following environment variables for user guest:

HOME=/home/guest
LOGNAME=guest
USER=guest
SHELL=/usr/bin/csh
PWD=/home/guest

In this example, user guest has specified the login shell as the C shell. The agent, therefore, runs the cmd1.ksh script using the environment defined in the $HOME/.login file.