This command executes an interactive UNIX command on a remote computer. This command is useful when the command to be executed will prompt for additional information (such as the UNIX
su command to switch user accounts) or may not return an exit code upon completion (such as starting up a new shell using
Note: This command can only be used from within a remote execution session, such as between
The following syntax is supported:
ksc_simple_respond “command” “prompt 1" “response 1" [“prompt 2" “response 2" … ]
ksc_simple_respond “command” -hide “prompt 1" “response 1" [“prompt 2" “response 2" … ]
There can be as many prompt-response pairs as necessary. Each prompt must be matched with a response, even if the response is an empty string. The prompts must appear in the exact order they will be displayed as the command is run. All arguments must be enclosed in quotes. In addition, if the command or any of the arguments contains double quotes (“), any other character can be used as the quote character. The first character after the string
ksc_simple_ respond will be interpreted as the quote character, and that character must appear at the beginning and end of each argument.
By using the
-hide option, the value passed in for the response will not be displayed in the execution log. In the log, the value will be displayed as ****. This flag should be used for each prompt/response pair that needs this treatment.
The execution engine will wait for each specified prompt. If a prompt does not appear for some reason, then the execution engine will continue to wait for it until the command times out.
If it becomes necessary to invoke a new shell while in a remote session, it would be ideal to simply use the command
sh. However, this can cause the execution engine to wait indefinitely while waiting for an exit code. To avoid this problem, the
sh command can be encapsulated in a
ksc_simple_respond command with no prompts as shown:
As another example, suppose it becomes necessary to switch to another user account while in a remote session using the
su command. This command always prompts for password, unless performed by a root user. By utilizing the
-hide feature, the password will not be displayed in the execution logs. This interactivity can be handled using
ksc_simple_respond as follows:
ksc_simple_respond "su <username>" -hide "word:" "<password>"
Note that “word:” was used as the prompt instead of the entire word “password:”. The execution engine will wait for the specified prompt string, whether it is all—or just a part—of the prompt text.
As one more example, consider the following Bourne shell command:
echo "Enter a string:\c"; read str; echo $str
Normally, this command line would cause the execution engine to hang while waiting for an exit code (the command will never exit because it is waiting for input), which would eventually timeout when the execution timeout time is reached. Use
ksc_simple_respond to process this command as shown (this command should be entered on a single line):
ksc_simple_respond #echo "Enter a string:\c"; read str; echo
str# #a string:# #my_value#
Since the command line contained double quotes, the pound sign (#) is used as the quote character. During execution, this command step will prompt “Enter a string:” and wait for input. The string “my_value” would be entered automatically, this value will then be echoed to the output device (in this case, the execution log), and execution will continue as normal with the next command step.