The Run Command

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

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

Option Description
Location This option specifies 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. The Identity can contain an SSH key.
Working Directory This option specifies the local directory from which the command is run, for local commands.
Host This option specifies the host on which the remote command is to be run and the port on which the host is listening for SSH connections. You must enter the host and port in the format as <host>:<port>.
User This option specifies the user ID to send to connect to the remote host, which is used for remote commands that requires a user and password combination to connect.
Password This option specifies the password that is associated with the specified user ID for remote commands.
Identity This option specifies the HCL OneTest API identity instead of a user and password combination.
After login, switch to user This option helps 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 work around this problem, use an exit step in the Run Command action.
(command) This option is used to enter the command or commands in the field by following the Connection parameters.
Wait for command execution to finish This option that is enabled as the default setting, specifies that the test run continues only after the commands are run in the test step. If disabled, the commands run in the background and the test continues to the next test step. If this option is not enabled, the Assert and Store tabs are unavailable.
Timeout
Note: The option is enabled only when the Wait for command execution to finish option is enabled.

This option specifies the time after which the command in a test step stops to run if the command is not able to complete its run. You must enter a timeout value in milliseconds, in the Timeout field.

If the Wait for command execution to finish option is disabled, you can ignore the timeout option and the command runs in the background and the test continues to the next test step.
Kill process at end of
Note: The option is enabled only when the Wait for command execution to finish option is enabled.
This option specifies that if the command is running in the background, the command can be forced to end its run when any of the following test resource completes its process:
  • Test
  • Scenario
  • Suite
  • Execution
If you select Suite or Scenario and the test is not run inside a suite or a scenario, then the process is forced to end when the test completes the run.
Note: When you are run 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). The remote SSH connection runs in a non-interactive shell, which can result in different settings in some of the system environment variables. You can consult your system or application administrator for assistance, or run the relevant environment scripts before you run the command, as shown in the following example: . ~/.profile ; <my_command>