Top
Systemwalker Runbook Automation Reference Guide
Systemwalker

3.2.3 Execute multiple commands

Description

This operation component connects to a host through SSH or Telnet communications, and then executes multiple commands interactively.

Use this component to operate the following devices.

Options

Basic Options

(1) hostname

Target host name or IP address where the operation component will be executed.

An argument error occurs if the host name or IP address is omitted.

If 'localhost', '127.0.0.1' or '::1' is specified for the host name or IP address, an argument error occurs.

The maximum length of the host name or IP address is 1,024 characters. An argument error occurs if this is exceeded.

(2) commandlinelist

This is the list of commands to be executed.

Multiple commands can be specified in the command list.

The following can be specified in the command:

  • Command name and argument to be executed

  • Interactive command response

The following table indicates how the operation component behaves when commands that include the following strings are specified.

Included string

Behavior

%PASSWORD%

The command is executed by replacing the "%PASSWORD%" string with the password for the administrator user that was specified using the "adminpassword" option.

An argument error will occur if the command list is omitted.

The maximum length of the string for the command list is 8,000 characters. An argument error occurs if this is exceeded.

Note the following points:

  • Separate each command by a linefeed character.

  • Specify commands in the order in which they will be executed.

  • When specifying interactive commands, specify the responses to prompts as well.

  • After the commands to be executed, specify the "exit" command to terminate the SSH or Telnet communications.

Example 1: Setting up configuration definitions for a network device (IPCOM EX2500)

terminal window 65535 65535                                      (1)
terminal pager disable                                           (2)
prompt disable                                                   (3)
admin                                                            (4)
%PASSWORD%                                                       (5)
configure terminal                                               (6)
load running-config                                              (7)
class-map match-any rba0101                                      (8)
match source-address ip 192.0.2.0/27                             (8)
!                                                                (8)
save running-config                                              (9)
save startup-config                                              (9)
exit                                                             (10)
exit                                                             (10)
exit                                                             (10)
exit                                                             (11)

(1) Sets the window size (height and width) for the terminal display to 65,535 characters.

(2) Disables the pager function for the terminal display.

(3) Disables the function that prompts the user.

(4) Switches to administrator EXEC mode.

(5) Executes the password for the administrator user that was specified using the "adminpassword" option.

(6) Switches to global configuration definition mode (real time).

(7) Starts editing the configuration definitions for running-config, and switches to global configuration definition mode (change).

(8) Creates filter conditions (class-map).

(9) Saves the running-config and startup-config.

(10) Returns to the previous mode.

(11) Ends the session and logs out.

Example 2: Obtaining details of disk errors for a storage device (ETERNUS DX80)

set clienv-show-more -scroll disable                                      (1)
show disk-error                                                           (2)
exit                                                                      (3)

(1) Disables page scroll mode.

(2) Displays details of the disk error.

(3) Ends the session and logs out.

Advanced Options

(1) connectiontype

This is the method used for communication with the host.

Specify either "SSH" or "Telnet". This option is not case sensitive.

An argument error will occur if a value other than "SSH" and "Telnet" is specified.

The character code for the communication method is not case sensitive.

If a communication method is not entered, "SSH" will be set.

(2) username

This is the user name used for communication with the host.

If the connected user name and password required for connection are not specified, the Configuration Management Database (CMDB) is searched based on the specified host name or IP address and Systemwalker Runbook Automation automatically sets the acquired connected user name as the value.

The maximum length of the connected user name is 1,024 characters. An argument error occurs if this is exceeded.

(3) password

This is the user password used for communication with the host.

If the connected user name and password required for connection are not specified, the Configuration Management Database (CMDB) is searched based on the specified host name or IP address and Systemwalker Runbook Automation automatically sets the acquired connected user password as the value.

The maximum length of the connected user password is 1,024 characters. An argument error occurs if this is exceeded.

(4) adminpassword

This is the password for the administrator user.

This is used when a string containing %PASSWORD% was specified in the commandlinelist option.

If the administrator user password is omitted, the command will search the Configuration Management Database (CMDB) based on the specified host name or IP address, and then Systemwalker Runbook Automation will automatically set the value for the administrator user password that has been acquired from the CMDB.

The maximum length of the administrator user password is 1,024 characters. An argument error occurs if this is exceeded.

(5) expectprompt

This is the list of prompts to be output by the host.

For the messages output by the host, the commands are executed one at a time interactively for each specified prompt matched.

Note the following points:

  • Specify the entire prompt (including spaces and symbols) rather than just part of the prompt. (If the last character of the prompt is a space, specify a space as well.)

  • To specify multiple prompts, separate each prompt by a linefeed character.

  • To execute interactive commands, specify the prompts used to prompt the user as well.

  • Prompts can be specified using regular expressions. To specify a regular expression, enclose the prompt with forward slashes ("/").

The maximum number of characters for the prompt list is 1,024. An argument error occurs if this is exceeded.

If the prompt list is omitted, the following value will take effect.

/[$#>]\s?\z/
/^[Pp]assword[: ][: ]?\z/

Example 1: An IPCOM EX2500 network device with host name "ipcom"

ipcom>
ipcom#
ipcom(check-sslvpn)#
ipcom(config)#
ipcom(edit)#
/^ipcom\(edit[a-z\-]*\)\# \z/
Password:

Example 2: An ETERNUS DX80 storage device where the prompt is "CLI>"

CLI>
(6) abort

This is the list of conditions which cause error termination following command execution.

The component will terminate with an error if a message output by the host matches one of these conditions.

Note the following points:

  • To specify multiple conditions for error termination, separate each condition by a linefeed character.

  • The component terminates with an error immediately if even one of these conditions is met.

  • The conditions for error termination can also be specified using regular expressions. To specify a regular expression, enclose the conditions for error termination with forward slashes ("/").

If the conditions for error termination are omitted, command execution will not terminate with an error.

The maximum length of the string for the conditions for error termination is 1,024 characters. An argument error occurs if this is exceeded.

Example 1: Target the standard error for an IPCOM EX2500 network device

<ERROR>
<ABORT>
<ALERT>
<EMERGENCY>
<CRITICAL>
Authentication failed.
Ambiguous command.
Unrecognized command.
Command incomplete.
Unknown commands or command parameters are insufficient.
Bad use <">.
Because the command is too long, it is not possible to recognize it.
A system of free memory is nothing. Please retry after a few minutes.
A system of free memory is low. Please take care.
A character code is invalid. Please use an ASCII character code.
Operation aborted by user.
Starting the system now. Please retry after a few minute.
This command cannot be executed because the system is stopping.

Example 2: Target the standard error for an ETERNUS DX80 storage device

/^Error: /
(7) charactercode

This is the character code for the host.

Specify "UTF-8", "SJIS" or "EUC".

An argument error will occur if a value other than "UTF-8", "SJIS" and "EUC" is specified.

The character code for the host is not case sensitive.

If this option is omitted, it will be set to "UTF-8".

(8) userprompt

For Telnet communications, this is the format for the login prompt that is requested at connection time by the host that executes commands interactively.

Note the following points:

  • Specify the entire prompt (including spaces and symbols) rather than just part of the prompt. (If the last character of the prompt is a space, specify a space as well.)

  • To specify multiple prompts, separate each prompt by a linefeed character.

  • To execute interactive commands, specify the prompts used to prompt the user as well.

  • Prompts can be specified using regular expressions. To specify a regular expression, enclose the prompt with forward slashes ("/").

If the login prompt format is omitted, the following value will take effect.

/[Uu]sername[: ][: ]?\z/
/[Ll]ogin[: ][: ]?\z/

The maximum length of the string for the login prompt format is1,024 characters. An argument error occurs if this is exceeded.

For SSH communications, the login prompt format is not used.

(9) passwordprompt

For Telnet communications, this is the format for the password prompt that is requested at connection time by the host that executes commands interactively.

Note the following points:

  • Specify the entire prompt (including spaces and symbols) rather than just part of the prompt. (If the last character of the prompt is a space, specify a space as well.)

  • To specify multiple prompts, separate each prompt by a linefeed character.

  • To execute interactive commands, specify the prompts used to prompt the user as well.

  • Prompts can be specified using regular expressions. To specify a regular expression, enclose the prompt with forward slashes ("/").

If the password prompt format is omitted, the following value will take effect.

/[Pp]assword[: ][: ]?\z/

The maximum length of the string for the password prompt format is 1,024 characters. An argument error occurs if this is exceeded.

For SSH communications, the password prompt format is not used.

(10) timeout

This is the completion timeout (seconds) for the execution of operation components.

Values between 300 and 86400 (1 day) can be specified.

Example) If the completion timeout is 10 minutes: 600

If the operation component has not finished executing even though the specified time has passed, the processing for the operation component will be interrupted with return value 201.

(11) retry

This is the retry count for the execution of operation components.

Specify the number of retry attempts to be used when operation components terminate with return value 161. Values between 0 and 5 can be specified.

If an operation component terminates with a return value other than "161" as a result of being re-executed from a retry, execution of the operation component will terminate even if the specified number of retries has not been reached. The return value for the operation component will be the value from the last time the operation component was executed.

Example) To retry the operation component twice: 2

(12) retry_interval

This is the retry interval (seconds) for operation components.

Specify the time to wait before a retry is attempted if operation components terminate with return value 161. Values between 1 and 14400 can be specified.

Example) To retry at 300 second intervals: 300


If the specification of the timeout, retry and retry_interval is omitted, and a value beyond the limits of the above-mentioned is input, the value specified with the operation componentscomponents definition file becomes effective. Refer to "2.5 Definition File for Operation Components" for details.

Return Values

Icon

Name

Return value

Description

Success

0

All commands have been executed.

Failure

161

An attempt to execute the command failed. If a retry count has been specified, retries will be attempted.

178

Processing has been interrupted because one of the error termination conditions has been met.

187

Authentication failed when an attempt was made to establish a network connection (via SSH or Telnet) to the host.

188

Network communications (SSH or Telnet) with the host have been disconnected.

189

An attempt to establish a network connection to the host via SSH or Telnet failed.

197

There is an error with an option specification. Alternatively, there is a problem with the information registered in the Configuration Management Database (CMDB).

200

Executing the command has terminated abnormally.

-

-

201

Execution of the operation component timed out.

202

The operation component has not been executed. There is a problem with the settings for executing the operation component.

203

Failed to execute the operation component. There is a problem with the Management Server environment.

205

The operation component has not been executed. There is a problem with the input information specification of the operation component.

206

The operation component has not been executed normally. There is a problem with the output information specification of the operation component.

207

The operation component has not been executed. The operation component may not have been registered on the Management Server.

208

The Automated Operation Process has been canceled because the Automated Operation Process was recovered while the operation component was executing.

Output information

Variable

Description

message

This variable will be set to the following message if the command is executed successfully.

The operation component was successful.

If the command fails to execute, the content of the error will be output as a string.

command_result

This variable is set to the string received from the host.

returnCode

This variable is set to the return value.

Example: The following example shows the output for the "command_result" variable when the component has been executed with the "commandlinelist" option as shown in Example 1 (under the explanation of the "commandlinelist" option above).

ipcom> terminal window 65535 65535
ipcom> terminal pager disable
ipcom> prompt disable
ipcom> admin
Password:
ipcom# configure terminal
ipcom(config)# load running-config
ipcom(edit)# class-map match-any rba0101
ipcom(edit-cmap)# match source-address ip 192.0.2.0/27
ipcom(edit-cmap)# !
ipcom(edit)# save running-config

Dynamic distribution of the configuration is carried out.

-----------------------------------------------------------------
The configuration was committed.
-----------------------------------------------------------------
ipcom(edit)# save startup-config

---------------------------------------------------------
The configuration was saved to startup-config.
The configuration is applied when the system is restarted.
Please restart the system.
---------------------------------------------------------
ipcom(edit)# exit
ipcom(config)# exit
ipcom# exit
ipcom> exit

Notes