How can we get the aliases setting for a user profile?
search cancel

How can we get the aliases setting for a user profile?


Article ID: 35752


Updated On:


CA Workload Automation AE - Business Agents (AutoSys) CA Workload Automation AE - Scheduler (AutoSys) Workload Automation Agent CA Workload Automation DE - System Agent (dSeries) CA Workload Automation DE - Business Agents (dSeries)


Customer is not able to get the 'aliases' definitions for each specific user.



Component: Workload Automation Agent

OS: Linux/ UNIX


Most shell built-in commands are not available in scripts.  Aliases are not expanded in non-interactive shells like the ones invoked by scripts or any background processes.



The alias setting is not interpreted at the job runtime such as the environment variable setting.

'alias' is a unix command, it forks a process.


In order to get the aliases defined for a user profile, you can use the attribute profile in the job definition as follows:

* ----------------- TEST1 ----------------- */

insert_job: TEST1 job_type: CMD
command: "alias > /home/sample/alias.txt"
machine: mymachine
owner: user1
date_conditions: 0
std_out_file: /home/log/${AUTO_JOB_NAME}_${AUTORUN}.log
std_err_file: /home/log/${AUTO_JOB_NAME}_${AUTORUN}.err
alarm_if_fail: 0
profile: /home/conf/user1/.profile


- This is extraction from the .profile of user 'user1'
alias lm='ls -al | more'
alias ll='ls -l'
alias la='ls -la'
alias lrt='ls -alrt'


- extraction from agentparm.txt

# this tells the agent to switch to the user home


- The result after run the job

root:  vi  /home/sample/alias.txt
la='ls -la'
ll='ls -l'
lm='ls -al | more'
lrt='ls -alrt'




The following command may be added in scripts to expand aliases.

shopt -s expand_aliases

Consult your Linux / Unix admin for more details on the above command.

Note:  It is not recommended to use aliases or any shell built-in commands in shell scripts, they are usually for interactive shell.  Using such variables can break when users/shell are changed or scripts move to another location.