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 – multiple commands can be entered on separate lines. The Test button can be used 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 how to run the command, locally or remotely. If you choose local, the command is executed on the machine 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. The Identity can contain an SSH key.
Working Directory For local commands, specifies the local directory from which the command is executed.
Host The host on which the remote command is to be executed, 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, specifies that a user/password combination is used to connect, and specifies the user ID to send for connecting to the remote host.
Password For remote commands, if User is selected, 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/password combination. See Adding an identity to the Physical view.
After login, switch to user Enable this option to switch to a different user, selecting the HCL OneTest™ API identity for the user to switch to, and specify the command to use (su, su -, or sudo) for switching.
(command) Enter the command or commands in the field below the Connection parameters.
Wait for command execution to finish Enable this option (default) to have HCL OneTest™ API wait for the command to execute and finish. If disabled, the command will run in the background and HCL OneTest™ API will continue 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 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 administrators for assistance, or run the relevant environment scripts before the command, as in the following example:

. ~/.profile ; <my_command>