Calling a Command
CommandCall API
- class CommandCall(config)
Creates a new CommandCall object.
- Arguments
config (commandCallConfig) – The CommandCall config object.
- Throws
Will throw an error when the first parameter is not an object.
- Throws
Will throw an error when an invalid command type is set.
- CommandCall.toXML()
- Returns
string – The command in xml format.
- clOptions()
CL Command Options
- Arguments
exec (string) – How to run the command. Valid options:
cmd
,system
, orrexx
. Default iscmd
.error (string) – Determines action when an error is encountered. Valid options are
on
,off
, orfast
. Default isfast
. Usingon
will cause the script execution to stop and log a full error report. Usingoff
orfast
continues executing the script. The Difference is thatfast
will log a brief error report andoff
will not.hex (string) – Whether to output data in hex format. Valid options are
on
oroff
. Default isoff
.before (string) – The CCSID to convert to before the command call.
after (string) – The CCSID to convert to after the command call.
- shOptions()
QSH and SH Command Options
- Arguments
rows (string) – Whether to split the output row by row. Valid options are
on
oroff
. Default isoff
.error (string) – Determines action when an error is encountered. Valid options are
on
,off
, orfast
. Default isfast
. Usingon
will cause the script execution to stop and log a full error report. Usingoff
orfast
continues executing the script. The Difference is thatfast
will log a brief error report andoff
will not.hex (string) – Whether to output data in hex format. Valid options are
on
oroff
. Default isoff
.before (string) – The CCSID to convert to before the command call.
after (string) – The CCSID to convert to after the command call.
- commandCallConfig()
CommandCall Configuration
- Arguments
command (string) – The command string to run.
type (string) – The type of the commmand:
cl
,qsh
,sh
. NOTE:qsh
type requiresXMLSERVICE >= 1.9.8
.commandOptions (clOptions|shOptions) – The options for the command.
Example
Call the RTVJOBA CL command
const { Connection, CommandCall } = require('itoolkit');
const { XMLParser } = require('fast-xml-parser');
const connection = new Connection({
transport: 'ssh',
transportOptions: { host: 'myhost', username: 'myuser', password: 'mypassword' },
});
const command = new CommandCall({ type: 'cl', command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)' });
connection.add(command);
connection.run((error, xmlOutput) => {
if (error) {
throw error;
}
const Parser = new XMLParser();
const result = Parser.parse(xmlOutput);
console.log(JSON.stringify(result));
});