Using the system or user-defined shortcut keys makes it easier to enter commands.
2.5 Configuration Examples
This section provides several examples for using command lines.
2.1 CLI Introduction
The command line interface (CLI) is the common tool for running commands.
2.1.1 Command Line Interface
You can configure and manage a ATN equipment by using the CLI commands.
When a prompt appears, you enter the command line interface (CLI) and interact with ATN equipment through CLI.
The system provides a series of configuration commands. You can configure and manage the ATN equipment by entering commands on CLI.
The characteristics of CLI are as follows:
l Local or remote configuration through AUX port.
l Local configuration through console port.
l Local or remote configuration through Telnet or Secure Shell (SSH).
l A user interface view for specific configuration management.
l Hierarchical command protection for users of different levels, that is, running the commands of the corresponding level.
l None authentication, password authentication and Authentication, Authorization and Accounting (AAA) to prevent the unauthorized user from accessing the ATN equipment.
l Entering "?" for online help at any time.
l Network testing commands such as tracert and ping for rapidly diagnosing a network.
l Abundant debugging information to help in diagnosing the network.
l The telnet command for directly logging in to and manage other ATN equipment.
l FTP service for file uploading and downloading.
l Running a history command, like DosKey.
l A command line interpreter provides intelligent command resolution methods such as key word fuzzy match and context conjunction. These methods make it easy for users to enter their commands.
NOTE
l The system supports the command with up to 512 characters. The command can be incomplete.
l The system saves the incomplete command to the configuration files in the complete form; therefore, the command may have more than 512 characters. When the system is restarted, however, the incomplete command cannot be restored. Therefore, pay attention to the length of the incomplete command.
2.1.2 Command Levels
The system adopts a hierarchical protection mode that has 16 command levels.
The default command levels are as follows:
l Level 0-Visit level: Commands of this level include commands of network diagnosis tool (such as ping and tracert) and commands that start from the local device and visit external device (such as Telnet client side).
l Level 1-Monitoring level: Commands of this level, including the display commands, are used for system maintenance and fault diagnosis.
l Level 2-Configuration level: Commands of this level are service configuration commands that provide direct network service to the user, including routing and network layer commands.
l Level 3-Management level: Commands of this level are commands that influence the basic operation of the system and provide support to the service. They include file system commands, FTP commands, TFTP commands, configuration file switching commands, power supply control commands, backup board control commands, user management commands, level setting commands, system internal parameter setting commands, and debugging commands that are used for fault diagnosis.
CAUTION
Not all display commands are of the monitoring level. For example, the display current-configuration and display saved-current-configuration commands are of the management level. For the level of a command, see the ATN 910 Command Reference.
To implement efficient management, you can increase the command levels to 0-15. For the increase in the command levels, refer to Chapter 4 "Basic Configuration" Configuring Command Levels in the ATN 910 Configuration Guide - Basic Configurations.
NOTE
l The default command level may be higher than the command level defined according to the command rules in application.
l Login users have the same 16 levels as the command levels. The login users can use only the command of the levels that are equal to or lower than their own levels. For details of login user levels, refer to Chapter 5 "User Login."
Searching Commands Based on Command Levels
You can search for all commands of a specific level simultaneously. The procedure is as follows:
1. Open the command reference (.chm.) file.
2. Click the "Search" tab. The search window will be displayed as shown in Figure 2-1.
Figure 2-1 Entering the search window
3. Enter a desired command level in the "Type in the word(s) to search for" textbox and click
"List Topics". All commands of the specified level will be displayed as shown in Figure 2-2.
Figure 2-2 Searching commands based on a specific level
2.1.3 Command Line Views
The command line interface has different command views. All the commands are registered in one or more command views. You can run a command only when you enter the corresponding command view.
# Establish connection with the ATN equipment. If the ATN equipment adopts the default configuration, you can enter the user view with the prompt of <HUAWEI>.
<HUAWEI>
# Type system-view, and you can enter the system view.
<HUAWEI> system-view [HUAWEI]
# Type aaa in the system view, and you can enter the AAA view.
[HUAWEI] aaa [HUAWEI-aaa]
NOTE
The prompt <HUAWEI> indicates the default ATN equipment name. The prompt <> indicates the user view and the prompt [] indicates other views.
Some commands that are implemented in the system view can also be implemented in the other views; however, the functions that can be implemented are command view-specific. For example, the mpls command (for enabling MPLS) can be run in the system view to enable the MPLS capability globally. Although it can also be run in the interface view, the MPLS capability is enabled only on the interface.
2.2 Online Help
When you enter command lines or configure services, online help offers real-time help in addition to the configuration guide.
Context
The command line of ATN 910 provides three types of online help:
l Full help l Partial help
l Error Messages of the Command Line Interface
2.2.1 Full Help
When you enter a command line, you can view the description of keywords or parameters in the command line through the Full Help.
Context
You can obtain the full help of the command line in the following ways.
Procedure
l Enter "?" in any command line view to display all the commands and their simple descriptions.
<HUAWEI> ?
l Enter a command and "?" separated by a space. If the key word is at this position, all key words and their simple descriptions are displayed. For example:
<HUAWEI> language-mode ? Chinese Chinese environment English English environment
Chinese and English are keywords; Chinese environment and English environment describe the keywords respectively.
l Enter a command and "?" separated by a space, and if a parameter is at this position, the related parameter names and parameter descriptions are displayed. For example:
[HUAWEI] ftp timeout ?
INTEGER<1-35791> The value of FTP timeout, the default value is 30 minutes [HUAWEI] ftp timeout 35 ?
<cr>
In the preceding display, INTEGER<1-35791> describes the parameter value; The value of FTP timeout, the default value is 30 minutes is a simple description of the parameter usage; <cr> indicates that no parameter is at this position. The command is repeated in the next command line. You can press Enter to run the command.
----End
2.2.2 Partial Help
When you enter a command line, you can obtain prompts on the keywords or parameters at the beginning of the string through the Partial Help.
Context
You can obtain the partial help of the command line in the following ways.
Procedure
l Enter a character string with a "?" closely following it to display all commands that begin with this character string.
<HUAWEI> d?
debugging delete dir display
l Enter a command and a character string with "?" closely following it to display all the key words that begin with this character string.
<HUAWEI> display b?
bfd bgp bootrom buffer bulk-stat
l Enter the first several letters of a key word in the command and then press Tab to display the complete key word on the condition that the letters uniquely identify the key word.
Otherwise, if you continue to press Tab, different key words are displayed. You can select the needed key word.
----End
2.2.3 Error Messages of the Command Line Interface
If an entered command passes the syntax check, the system executes it. Otherwise, the system prompts an error message.
All the commands entered by the user are run correctly, if the grammar check has been passed.
Otherwise, error messages are reported to the user. See Table 2-1 for the common error messages.
Table 2-1 Common error messages of the command line Error messages Cause of the error
Unrecognized command The command cannot be found The key word cannot be found Wrong parameter Parameter type error
The parameter value exceeds the limit Incomplete command Incomplete command entered
Too many parameters Too many parameters entered Ambiguous command Indefinite parameters entered
2.3 Features of Command Line Interface
You can edit command lines, display command lines, use the regular expression for command lines, and invoke historical commands.
2.3.1 Editing
The editing function of command lines helps you edit command lines or obtain help by using certain keys.
The command line supports multi-line edition. The maximum length of each command is 512 characters.
Keys for editing that are often used are shown in Table 2-2.
Table 2-2 Keys for editing
Key Function
Common key Inserts a character in the current position of the cursor if the editing buffer is not full and the cursor moves to the right. Otherwise, an alarm is generated.
Backspace Deletes the character on the left of the cursor that moves to the left. When the cursor reaches the head of the command, an alarm is generated.
Left cursor key ← or Ctrl_B
Moves the cursor to the left by the space of a character. When the cursor reaches the head of the command, an alarm is generated.
Right cursor key → or Ctrl_F
Moves the cursor to the right by the space of a character. When the cursor reaches the end of the command, an alarm is generated.
Tab Press Tab after typing the incomplete key word and the system runs the partial help:
l If the matching key word is unique, the system replaces the typed one with the complete key word and displays it in a new line with the cursor a space behind.
l If there are several matches or no match at all, the system displays the prefix first. Then you can press Tab to view the matching key word one by one. In this case, the cursor closely follows the end of the word and you can type a space to enter the next word.
l If a wrong key word is entered, press Tab and the word is displayed in a new line.
2.3.2 Displaying
All command lines have the same displaying feature. You can construct the displaying mode as required.
You can control the display of information on CLI as follows:
l Display prompt and help information in both Chinese and English.
l When the information displayed exceeds a full screen, it provides the pause function. In this case, the user has three choices as shown in Table 2-3.
Table 2-3 Keys for displaying
Key Function
Ctrl_C Stops the display and running of the command.
Space Continues to display the information on the next screen.
Enter Continues to display the information on the next line.
2.3.3 Regular Expressions
The regular expression is a mode matching tool. You can construct the matching mode based on certain rules, and then match the mode with the target object.
The regular expression is an expression that describes a set of strings. It consists of common characters (such as letters from "a" to "z") and particular characters (also named metacharacters).
The regular expression is a template according to which you can search for the required string.
A regular expression can provide the following functions:
l Searching for and obtaining a sub-string that matches a rule in the string.
l Substituting a string according to a certain matching rule.
Formal Language Theory of the Regular Expression
The regular expression consists of common characters and particular characters.
l Common characters
Common characters are used to match themselves in a string, including all upper-case and lower-case letters, digits, punctuations, and special symbols. For example, a matches the letter "a" in "abc", 202 matches the digit "202" in "202.113.25.155", and @ matches the symbol "@" in "[email protected]".
l Particular characters
Particular characters are used together with common characters to match the complex or particular string combination. Table 2-4 describes particular characters and their syntax.
Table 2-4 Description of particular characters
\ Defines an escape character, which is used to mark the next character (common or particular) as the common character.
\* matches "*".
^ Matches the starting position of the string.
^10 matches "10.10.10.1" instead of
"20.10.10.1".
$ Matches the ending position of the string.
1$ matches "10.10.10.1" instead of
"10.10.10.2".
* Matches the preceding element zero or more times.
10* matches "1", "10", "100", and
"1000".
(10)* matches "null", "10", "1010", and "101010".
+ Matches the preceding element one or more times
10+ matches "10", "100", and
"1000".
(10)+ matches "10", "1010", and
"101010".
? Matches the preceding element zero or one time.
10? matches "1" and "10".
(10)? matches "null" and "10".
. Matches any single character. 0.0 matches "0x0" and "020".
.oo matches "book", "look", and
"tool".
() Defines a subexpression, which can be null. Both the expression and the subexpression should be matched.
100(200)+ matches "100200" and
"100200200".
x|y Matches x or y. 100|200 matches "100" or "200".
1(2|3)4 matches "124" or "134", instead of "1234", "14", "1224", and
"1334".
[xyz] Matches any single character in the regular expression.
[123] matches the character 2 in
"255".
[^xyz] Matches any character that is not contained within the brackets.
[^123] matches any character except for "1", "2", and "3".
[a-z] Matches any character within the specified range.
[0-9] matches any character ranging from 0 to 9.
[^a-z] Matches any character beyond the specified range.
[^0-9] matches all non-numeric characters.
Particul ar characte r
Syntax Example
_ Matches a comma "," left brace "{", right brace "}", left parenthesis "(", and right parenthesis ")".
Matches the starting position of the input string.
Matches the ending position of the input string.
Matches a space.
_2008_ matches "2008", "space 2008 space", "space 2008", "2008 space", ",2008,", "{2008}",
"(2008)", "{2008", and "(2008}".
NOTE
Unless otherwise specified, all characters in the preceding table are displayed on the screen.
l Degeneration of particular characters
Certain particular characters, when being placed at the following positions in the regular expression, degenerate to common characters.
– The particular characters following "\" is transferred to match particular characters themselves.
– The particular characters "*", "+", and "?" placed at the starting position of the regular expression. For example, +45 matches "+45" and abc(*def) matches "abc*def".
– The particular character "^" placed at any position except for the start of the regular expression. For example, abc^ matches "abc^".
– The particular character "$" placed at any position except for the end of the regular expression. For example, 12$2 matches "12$2".
– The right bracket such as ")" or "]" being not paired with its corresponding left bracket
"(" or "[". For example, abc) matches "abc)" and 0-9] matches "0-9]".
NOTE
Unless otherwise specified, degeneration rules are applicable when preceding regular expressions serve as subexpressions within parentheses.
l Combination of common and particular characters
In actual application, a regular expression combines multiple common and particular characters to match certain strings.
Specifying a Filtering Mode in Command
CAUTION
The ATN 910 uses a regular expression to implement the filtering function of the pipe character.
A display command supports the pipe character only when there is excessive output information.
When the output information is queried according to the filtering conditions, the first line of the command output starts with the information containing the regular expression.
The command can carry the parameter | count to display the number of matching entries. The parameter | count can be used together with other parameters.
For the commands supporting regular expressions, the three filtering methods are as follows:
l | begin regular-expression: displays the information that begins with the line that matches regular expression.
l | exclude regular-expression: displays the information that excludes the lines that match regular expression.
l | include regular-expression: displays the information that includes the lines that match regular expression.
NOTE
The value of regular-expression is a string of 1 to 255 characters.
Specify a Filtering Mode when Information is Displayed
When a lot of information is displayed, you can specify a filtering mode in the prompt "---- More ----".
l /regular-expression: displays the information that begins with the line that matches regular expression.
l -regular-expression: displays the information that excludes lines that match regular expression.
l +regular-expression: displays the information that includes lines that match regular expression.
2.3.4 History Commands
The command line interface provides a function similar to DosKey, which can automatically save historical commands. You can invoke the historical commands saved on the command line interface at any time and run them again.
By default, the system saves 10 history commands at most for each user. The operations are as shown in Table 2-5.
Table 2-5 Access the history commands
Action Key or Command Result
Display the history commands.
display history-command
Display the history commands entered by users.
Access the last history command.
Up cursor key↑ or Ctrl_P
Display the last history command if there is an earlier history command. Otherwise, a bell is generated.
Access the next history
command.
Down cursor key ↓ or Ctrl_N
Display the next history command if there is a later history command. Otherwise, the command is cleared and a bell is generated.
NOTE
On the HyperTerminal of Windows 9X, cursor key ↑ is invalid as the HyperTerminals of Windows 9X define the keys differently. In this case, you can replace the cursor key ↑ with Ctrl_P.
When you use the history commands, note the following:
l The saved history commands are the same as that those entered by users. For example, if the user enters an incomplete command, the saved command also is incomplete.
l If the user runs the same command several times, the earliest command is saved. If the command is entered in different forms, they are considered as different commands.
For example, if the display ip routing-table command is run several times, only one history command is saved. If the disp ip routing command and the display ip routing-table command are run, two history commands are saved.
2.3.5 Batch Command Execution
By running pre-defined command lines in batches, you can simplify the operation of entering common commands and improve efficiency.
Context
Log in to the ATN equipment from the client and do as follows:
Procedure
Step 1 Run the batch-cmd edit to edit commands to be run in batches.
The batch-cmd edit command can be used by only one user at a time.
The maximum length of a command (including the incomplete command) to be entered is 512 characters.
When editing commands, press Enter to complete the editing of each command.
NOTE
After running the batch-cmd edit command to successfully edit the commands to be executed in batches, the system deletes the original commands to be run in batches.
The commands that are already edited are saved in memory and are deleted for ever when the system is restarted.
Step 2 After all commands are edited, you can press the shortcut buttons Ctrl+Z to exit the editing state and return to the user view.
Step 3 Run the batch-cmd execute to execute commands in batches.
The batch-cmd execute command can be used by only one user at a time.
The sequence of running commands is the same as the sequence of editing commands.
----End
2.4 Shortcut Keys
Using the system or user-defined shortcut keys makes it easier to enter commands.