Command line handler
The CMDLINE handler takes a command and an endpoint as input. The CMDLINE handler uses the SSH protocol to run the command on the target system and return the results.
A metadata parameter is passed during a system invocation when the handler is called. The parameter is a map that contains the name of the endpoint that represents the target system. The caller can target any system at run time and pass the endpoint to the command handler. The caller uses whatever configuration the endpoint has at the time of the invocation.
CMDLINE handler properties
The CMDLINE handler has the following properties:
- CMDTIMEOUT – The timeout value for command execution
- CONNTIMEOUT – The timeout value for the connection
- USERNAME – The user name for the connection
- PASSWORD – The password for corresponding user name
- HOST – The host name of target where command is run
- PORTNO – The port number of target where the command is run
- IGNORESETUPERR – A boolean value that indicates whether to ignore an error running the setup command
- RETRYINTERVAL – The time to wait between retrying a command
- MAXRETRY – The number of attempts to run a command before returning an exception
- SSHEXIT – The Java™ exit class that can be implemented to customize processing of the handler
Command data parameters
The data parameter is a byte array representation of an XML document. The data parameter contains the following information:
- The tags that correspond to the setup command
- The working directory
- The command to run
- Any substitution parameters
Available tags
The following tags are available:
- CLWORKINGDIR – A directory to change (
cd
) to on the remote system before the command is run. - CLSSETUPCMD – A setup command to be run before the main command. Use this tag for any environmental setup that must occur on the remote system before the main command is issued.
- CLCMDPATTERN - A string that defines the pattern of the command
to be run. The format of this pattern is similar to the java.text.MessageFormat class.
An example is
ls -l {0}
, where {0} represents a parameter that is substituted. - CLSUB0 - The value to substitute into positions that are marked by {0} in the CLCMDPATTERN.
- CLSUB1- The value to substitute into positions that are marked by {1} in the CLCMDPATTERN.
- CLSUBn - The value to substitute into positions that are marked by {n} in the CLCMDPATTERN. A CLSUBn tag must correspond to each substitution position in the CLCMDPATTERN tag.
Command results
The return byte array representation of an XML document contains the results of the command. The XML document contains tags that correspond to the return value, STDOUT and STDERR.
The following tags are available:
- CLRETURNCODE – The return code from the remote command.
- CLRESPONSEOUT – The data that is returned by the remote command in STDOUT tag.
- CLRESPONSEERR – The data that is returned by the remote command in STDERR tag.