Run Command

The Run Command action executes one or more commands or programs that are normally executed from the command line or shell. This action can validate or store the command’s output, or stop and start system resources that might be used within a test or scenario.

Enter one or more scripts, programs, or executables to run under the Config tab. You can enter multiple commands on separate lines. You can use Test to see the results of the command at run time. The options for running the command are specified in the following table:

Option Description
Location Select to run the command locally or remotely. If you choose local, the command is run on the system where HCL OneTest™ API is installed. If you choose Remote using SSH, the command is run on the remote host specified and you have the option to specify a User ID and Password, or an Identity. TheIdentity can contain an SSH key.
Working Directory For local commands this option specifies the local directory from which the command is run.
Host The host on which the remote command is to be run and the port on which the host is listening for SSH connections. The host and port must be entered in the form host:port.
User For remote commands this option specifies that a user and password combination is used to connect, and specifies the user ID to send to connect to the remote host.
Password For remote commands, if User is selected, this option specifies the password that is associated with the specified user ID.
Identity Enable this option to specify a HCL OneTest API identity instead of a user and password combination. See Adding an identity to the Physical view.
After login, switch to user Enable this option to switch to a different user by selecting the HCL OneTest API identity for the user to switch to, and by specifying the command to use (su, su -, or sudo) for switching.
Note: If you use the Run Command action with the switch to user option and use su with an identity, the command does not complete. To workaround this problem use an exit step in your Run commands.
(command) Enter the command or commands in the field following the Connection parameters.
Wait for command execution to finish Enable this option (default) to have HCL OneTest API wait for the command to run and finish. If disabled, the command runs in the background and HCL OneTest API continues to the next test step. If this option is not enabled, the Assert and Store tabs are unavailable.
Kill process at end of ... If the command is running in the background, you can enable this option to kill the command once the containing test resource finishes (Test, Scenario, Suite, or Execution). If you select Suite or Scenario and the test is not run inside a suite or a scenario, then the process ends at the end of the test.

This option is unavailable if Wait for command execution to finish is enabled.

Note: When you are running commands remotely by using SSH, you can experience a different behavior than if you were logged in to the actual system (for example, "command not found" error). Remote SSH connections run a non-interactive shell, which can result in different settings in some of the system environment variables. Consult your system or application administrator for assistance, or run the relevant environment scripts before the command, as in the following example:

. ~/.profile ; <my_command>
Feedback