Run command error
search cancel

Run command error

book

Article ID: 43238

calendar_today

Updated On:

Products

CA Release Automation - Release Operations Center (Nolio) CA Release Automation - DataManagement Server (Nolio)

Issue/Introduction

Issue: 

Using the "Run Command Line" action to run as another user (example: user1), and setup on the remote machine to use sudo, an error is returned about the command/script not being found. But the command executes successfully when manually connecting via ssh as user1.

 

Environment:  

Release Automation 5.x.x - 6.x.x

 

Cause: 

The problem is related to the profiles loaded for a user when using sudo. If you login via ssh as user1 and run the command "env" and then login via ssh as user2 and run: sudo -u user1 env

then you will notice that the outputs are not the same. The use of sudo is why.

 

Resolution:

1. You can use the Environment Variables Names and Environment Variables Values fields in the "Run Command Line" action to update the necessary environment variables to get your action to work; or

2. You can load the necessary profile(s) before running your command by doing something like this:  sh /home/<username>/.bashrc; cat /tmp/test.txt 

The semi-colon acts as a terminator between commands. So first it loads the profile and then it runs the command you want to run.

 

Additional Information:

None.

Environment

Release: NOLNAC99000-6.1-Nolio-Automation Center
Component: