The system provides a set of prompts and commands for each device type that it supports. During the process of logging in to a device, the system determines which command to send based command prompts. However, the built-in prompts and commands may not fit in some special scenarios, which may cause login failures.
To tackle with this issue, you can customize prompts and commands for a CLI mode in device settings.
Note: The customized prompts and commands in device settings will not be synchronized to device drivers. Only users with System Management privilege can access device drivers to add new CLI modes. See Device Driver Properties for more details.
1.Right-click the device on a map page and select Shared Device Settings from the drop-down menu.
2.In the Shared Device Settings of the device, click Advanced on the CLI tab.
3.Toggle the switch to enable the login script.
4.Configure the prompts and commands for a specific mode. Take Non-privilege Mode as an example.
1)Move your mouse pointer to the Non-privilege Mode entry, click the drop-down icon and select Edit.
2)In the Edit Mode dialog, add prompts and commands by either of the following ways:
▪Add prompts and commands in text.
▪Add prompts and commands using JSON script.
Note: The content defined on the UI tab and JSON tab is synchronized with each other. Therefore, you can select either way to define prompts and commands for only once.
3)In the Add CLI commands to this mode field, enter the commands that can be executed in this mode.
4)Click OK.
On the UI tab, click Add Row to add a new pair of prompt and command..
The definition contains three fields:
Field |
Description |
Expected Prompt |
A prompt to require a command input to continue the login process, such as the prompt Enter CTRL-Y to begin that you may encounter when logging to some Avaya switches. ▪The input supports text, such as Enter CTRL-Y to begin, and regex expression, such as regex:.+?to +begin.+. ▪The input supports the variable $(hostname), such as $(hostname)> and $(hostname)#. Note: The prompt cannot be empty and cannot exceed 255 characters. |
Send Command |
The corresponding command that the system sends out after receiving an expected prompt. ▪Besides common commands such as enable, exit and end, the system supports sending a key or combination keys on your keyboard to a device. See Supported Key and Combination Key Commands for details. ▪The system supports the following variables in the command input: o$(username) — the non-privileged username of a device. o$(password) — the non-privileged password of a device. o$(privilege username) — the privileged username of a device. o$(privilege password) — the privileged password of a device. Note: The command cannot be empty and cannot exceed 255 characters. |
Hide Command |
Show the content in the Send Command column as ciphertexts. |
On the JSON tab, configure the prompts and commands by using JSON scripts. The JSON definition contains the following elements:
Element |
Type |
Description |
expected_Items |
Array |
A collection of all matched items in the script. |
expected_prompt |
string |
A prompt to indicate a command input to continue the login process, such as the prompt Enter CTRL-Y to begin that you may meet when logging to some Avaya switches. ▪The input is a string that supports the regex expression, such as "regex:[\>\#]". Note: About special characters such as \,',r in the regex expression, you need to add escape characters ahead of them in JSON. For more details about JSON character escaping, see JSON RFC document. ▪The input string supports the variable $(hostname, such as "$(hostname)>". Note: The prompt cannot be empty and cannot exceed 255 characters. |
send_command |
string |
The corresponding command to send after receiving an expected prompt. ▪Besides common commands such as enable, exit and end, the system supports sending a key or combination keys on your keyboard to a device. See Supported Key and Combination Key Commands for details. ▪The system supports the following variables in the command input: o$(username) — the non-privileged username of a device. o$(password) — the non-privileged password of a device. o$(privilege username) — the privileged username of a device. o$(privilege password) — the privileged password of a device. Note: The command cannot be empty and cannot exceed 255 characters. |
hide |
bool |
Determine whether to show the content in the Send Command column. |
Sample JSON Script:
{
"expected_items": [
{
"expected_prompt": "regex:login.*:",
"send_command": "$(username)",
"hide": false
},
{
"expected_prompt": "password:",
"send_command": "$(password)",
"hide": false
},
{
"expected_prompt": "regex:Terminal type\\? \\[.+\\]",
"send_command": "xterm",
"hide": false
},
{
"expected_prompt": "regex:[\\>\\#]",
"send_command": "!/bin/bash",
"hide": false
},
{
"expected_prompt": "regex:[\\>\\#]",
"send_command": "tmsh",
"hide": false
},
{
"expected_prompt": "regex:\\S.+?\\)[\\>\\#]",
"send_command": "",
"hide": false
}
]
}
On devices of some vendors, a key or combination key needs to be sent during the login process. The system supports the following types of keys or combination keys.
Note1: The system uses the square brackets [ ] to recognize a key and combination keys to send, so include the key or combination key with the square brackets during the definition.
Note2: Add + \r or - \r after a key or combination key command to tell the system whether to send the command with the Enter key.
▪+ \r: Send a command with the Enter key. For example, [Ctrl+Y, X] +\r.
▪- \r: Send a command without the Enter key. For example, [Ctrl+Y] -\r.
No. |
Key/Combination Key |
Description |
1 |
[Ctrl+Y] |
The Ctrl+Y command is sent. Y is a letter in a lower or upper case from A to Z. |
2 |
[Shift+Y] |
The Shift+Y command is sent. Y is a letter in a lower or upper case from A to Z. |
3 |
[Alt+Y ] |
The Shift+Y command is sent. Y is a letter in a lower or upper case from A to Z. |
4 |
[Ctrl+Shift+Y] |
The Ctrl+Shift+Y command is sent. Y is a letter in a lower or upper case from A to Z. |
5 |
[Ctrl+Alt+Y] |
The Ctrl+ALT+Y command is sent. Y is a letter in a lower or upper case from A to Z. |
6 |
[ Shift+Alt+Y] |
The Shift+ALT+Y command is sent. Y is a letter in a lower or upper case from A to Z. |
7 |
[Ctrl+Y, X] |
This command includes pressing the Ctrl +X combination key and then pressing the Y key separately (without holding Ctrl +X). ▪X and Y are both letters in a lower or upper case from A to Z. ▪Ctrl +Y in this case can be any type of combination keys from No.1 to No.6, such as [Ctrl+Shift+Y, X]. |
8 |
[Ctrl+Y, Ctrl+X] |
The Ctrl +Y+X command is sent. ▪X and Y are both letters in a lower or upper case from A to Z. ▪Ctrl +Y or Ctrl+X in this case can be any type of combination keys from No.1 to No.6, such as [Ctrl+Shift+Y, Ctrl+X]. |
9 |
[Esc] |
The Esc command is sent. |
10 |
[Enter] |
The Enter command is sent. |
11 |
[Space] |
The Space command is sent. |
12 |
[Y] |
The Y command is sent. Y is a letter in a lower or upper case from A to Z. |
13 |
[Ctrl+\]] |
The Ctrl+] command is sent. Because the system uses [ ] to include a key or combination key, to avoid the conflict of the ] character, the escape character \ is used. |