4.7 Controlling CLI Output on the Screen


When working in the JUNOS CLI, you may be looking for specific information, viewing the output of show commands for monitoring and troubleshooting, or reading configuration files. These outputs and files can be very lengthy and difficult to read. To help you deal with this output, the JUNOS CLI includes a variety of tools that will allow you to control how output is displayed and provide you with a mechanism for filtering and searching the output.

4.7.1 Displaying Output

When output is displayed on the screen, it will be listed one page at a time. The size of the page is determined by the set CLI screen-length command. This means that when the amount of information that needs to be displayed is greater than the screen length, the CLI will separate each page of information with a -(more)- prompt. Once the -(more)- prompt is displayed, you can search the output. The following example shows one page of the displayed output and the -(more)- prompt:

 lab@Chicago> show configuration  version 5.0R3.3; system {     host-name Chicago;     login {         user test {             uid 2001;             class superuser;             authentication {                 encrypted-password "$Upc0"; # SECRET-D ATA             }         }         user lab {             uid 2000;             class superuser;             authentication {                 encrypted-password "0"; # SECRET-D ATA ---(more)--- 

As was mentioned previously, there are many useful tools for displaying output to the CLI screen. The following example lists some of these different tools. If you execute a command, you can use the pipe ( ) parameter to customize the way output is displayed on the screen. The pipe parameter, in this example, permits additional parameters that can be used to search and display information from the router output. This parameter is quite useful and comes in handy when you are trying to find specific information in large files, such as routing tables.

 lab@Chicago> show configuration  ?  Possible completions:   count                Count occurrences   display              Display additional information   except               Show only text that does not match a pattern   find                 Search for the first occurrence of a pattern   hold                 Hold text without exiting the --More-- prompt   match                Show only text that matches a pattern   no-more              Don't paginate output   resolve              Resolve IP addresses   save                 Save output text to a file   trim                 Trim specified number of columns from start of line 

Note

The configuration-mode pipe options will include a compare parameter and some additional display commands. We will cover these in the configuration-mode section.


4.7.2 Filtering Output

From time to time, you might find it helpful to filter the displayed output. Prior to executing a command that would display output to the CLI screen, you have options to filter the displayed output. These options can be used to count the number of lines in a file, match specific items, find a certain parameter, and so on. In the following examples, we will discuss these different options and show an example of each.

4.7.2.1 count

The count parameter is used for counting the number of lines in a file or table. The syntax is as follows :

 show route protocol isis  count 

The following examples show how to use the count parameter. In the first statement, the user counts the number of lines in the configuration file. In the second, the user counts the number of lines in the isis section only of the same configuration file:

 lab@Chicago> show configuration  count  Count: 143 lines lab@Chicago> show route protocol isis  count Count: 59 lines 
4.7.2.2 display

The display command is used to display the output in XML format. The syntax is as follows:

 show configuration  display xml 

The next example shows the output of the display command from the first instance of interfaces to the end of the file in XML format:

 lab@Chicago> show configuration  display xml  find interfaces      <interfaces>         <interface>             <name junos:key="key">fxp0</name>             <speed>100m</speed>             <link-mode>full-duplex</link-mode>             <unit>                 <name junos:key="key">0</name>                 <encapsulation>802.3-llc</encapsulation>                 <family>                     <inet>                         <address>                             <name junos:key="key">192.168.161.16/24</name>                         </address>                     </inet>                 </family>             </unit>         </interface>     </interfaces> </configuration> </rpc-reply> 
4.7.2.3 except

The except parameter allows you to display all output except what you specify after the except option. They syntax is as follows:

 show configuration  except <pattern>  pattern to avoid  

The example below shows the configuration file, first without the except option and then with it. Notice that the uid parameter is visible in the output. When we use the except option, we are going show everything in the configuration file except for uid .

 lab@Chicago> show configuration  version 5.0R3.3; system {     host-name m5lower;     login {         user test {  uid 2001;  class superuser;             authentication {                 encrypted-password "$A"; # SECRET-DATA             }         }         user lab {  uid 2000;  class superuser;             authentication {                 encrypted-password "niG0"; # SECRET-DATA lab@Chicago> show configuration  except uid version 5.0R3.3; system {     host-name m5lower;     login {         user test {             class superuser;             authentication {                 encrypted-password "$A"; # SECRET-DATA             }         }         user lab {             class superuser;             authentication {                 encrypted-password "niG0"; # SECRET-DATA 
4.7.2.4 find and match

To find specific information in the Juniper Networks CLI, use the find and match parameters. The find option will display all output, including the pattern you specify, to the end of the file. The match option will display exactly what you specify and only that. The syntax for these is as follows:

 show route  find <pattern>  pattern to search for  show route  match <pattern>  pattern to match against  

The following examples show how these parameters are used:

 lab@Chicago> show route  find 192.168.161.0  192.168.161.0/24   *[Direct/0] 3d 02:05:58                     > via fxp0.0 192.168.161.16/32  *[Local/0] 3d 02:05:58                      Local lab@Chicago> show route  match 192.168.161.0 192.168.161.0/24   *[Direct/0] 3d 02:06:08 

Note

If you are using find or match on an entire Internet routing table, for example, there may be a noticeable delay as the Juniper Networks router does the search. This is normal and should not alarm the user.


4.7.2.5 hold

The hold option is useful for scrolling up and down through files. Normally, when a command is displayed on the screen, it is displayed one page at a time; when the output reaches the end of the file, you are sent back to the prompt. This hold option will cause the output to stop at the end of the file before sending you back to the prompt. This gives you the ability to scroll up and down through the output.

The first output, in the example below, shows the configuration file. The user typing the show configuration command at the Chicago prompt indicates this. When the output is displayed, the -(more)- prompt appears to indicate the end of that screen and to prompt the user to press a key to see more. The user then presses the space bar, and the rest of the file is displayed, after which the user is returned to the prompt.

The second output shows the same command used again, but this time it includes the hold option. When the output is displayed in this example, the first page is the same. However, when the last page is displayed, the user is not sent back to the prompt. Instead, the user sees 100% . This is an indication to the user that he has reached the end of the file, but not been sent back to the prompt. That being the case, the user can now use the up and down arrows to scroll through the file. Pressing the enter key or space bar when 100% is displayed will return the user to the prompt. Using Ctrl-c or pressing the q key at anytime will also cause an exit.

 lab@Chicago> show configuration  version 5.0R2.4; system {     host-name Chicago;     login {         class superuser {             permissions all;         }         user lab {             uid 2000;             class superuser;             authentication {                 encrypted-password "lGdV/"; # SECRET-DATA             }         }     }     services {         ftp;         ssh;         telnet;     } } interfaces {  ---(more)---  fxp0 {         speed 100m;         link-mode full-duplex;         unit 0 {             encapsulation 802.3-llc;             family inet {                 address 192.168.161.16/24;             }         }     } } lab@Chicago> show configuration  hold version 5.0R2.4; system {     host-name Chicago;     login {         class superuser {             permissions all;         }         user lab {             uid 2000;             class superuser;             authentication {                 encrypted-password "lGdV/"; # SECRET-DATA             }         }     }     services {         ftp;         ssh;         telnet;     } } interfaces {  ---(more)---  fxp0 {         speed 100m;         link-mode full-duplex;         unit 0 {             encapsulation 802.3-llc;             family inet {                 address 192.168.161.16/24;             }         }     } }  ---(more 100%)---  
4.7.2.6 save

There may be times when you find it necessary to save captured output to a file. If that is the case, you might want to use the save option. With the save option, instead of the output being displayed on the screen, the output will be saved to a file. This functionality is similar to redirecting output to a file in UNIX. The save option will allow the filename specified to be created and saved to a specified location. By default, if path is not specified, the file will be stored in the user's home directory. It is also possible to send the file to a remote location via FTP.

If you want to see the files that you have saved locally, you can use the file list command to list them. If you type the file list command on the command line, the list displayed shows the newly saved file. You can also read the files by using the file show command. Saving a file to an FTP server can be accomplished by specifying the destination in URL format. The syntax for these commands is as follows:

 show configuration  save <filename>  Output file name (or URL)  file list   <[Enter]> file show <filename>  Filename to display  

The example below shows the process of saving the file, both locally and via FTP. The file named my_local_file has been created to include the output of the show configuration command and is saved locally. This is done by using the command show configuration save my_local_file . This command will create a file named my_local_file and will redirect the output of the show configuration command. To list the files saved on the router, the user can use the file list command. If the user wants to display the contents of the newly saved file named my_local_file , he or she can do this by typing the file show my_local_file command.

 lab@Chicago> show configuration  save my_local_file  Wrote 54 lines of output to 'my_local_file' lab@Chicago> file list .ssh/ my_local_file lab@Chicago> file show my_local_file version 4.3R1.4; system {     host-name Chicago;     ports {         console type vt100;     }     login {         class superuser {             permissions all;         }         user lab {             uid 2000; lab@Chicago> show configuration  save ftp://192.168.5.107/my_ftp_file Wrote 54 lines of output to 'ftp://192.168.5.107/my_ftp_file' 
4.7.2.7 trim

The trim option lets you trim columns off of the displayed output. The syntax for this is as follows:

 show configuration  trim <columns>  Number of columns to trim  

In the example below, the user has typed the show configuration command with the trim set to three. Notice that the first three letters of version and system are no longer displayed. They have been trimmed off.

 lab@Chicago> show configuration  trim 3  sion 4.3R1.4; tem {  host-name Chicago;  ports {      console type vt100; 

4.7.3 Searching the Output

When the -(more)- prompt lets you know that there is more information to be displayed, you can use JUNOS CLI keyboard sequences to search and manipulate the on-screen data. Table 4-2 lists these keyboard sequences.

Table 4-2. Keyboard Sequences for Searching and Manipulating On-screen Data
Function Keyboard Sequence
List the keyboard sequences available when the -(more)- prompt is displayed h
Display output all at once (like no-more option) N
Repeat previous search for a string n
Search for a text string (like match option) m or M
Search, ignoring a text string (like except option) e or E
Do not redisplay prompt after displaying the output (like hold option) H
Clear match conditions and display complete output c or C
Save output to a file (like save option) s or S
Scroll down one line Enter, k, Ctrl-m, Ctrl-n, down arrow
Scroll down a half screen Tab, d, Ctrl-d, Ctrl-x
Scroll down whole screen Space, Ctrl-f
Scroll down to bottom of output Ctrl-e, G
Display previous line output j, Ctrl-h, Ctrl-p, up arrow
Scroll up a half screen u, Ctrl-u
Scroll up a whole screen b, Ctrl-b
Scroll to top of screen g, Ctrl-a
Search forward /string
Search backward ?string

The / parameter can be quite useful for searching files. The following example explains its use. The user has typed the show configuration command, and the output will now be displayed one page at a time. However, instead of scrolling through the configuration file page by page, the / can be used to search the file for specific information. Here we want to find the first occurrence of bgp . The user can do this by typing the / and entering the string to search for. In this case, the user types bgp when Search For: is displayed. The result is that the first occurrence of bgp is displayed on the screen.

 lab@Chicago> show configuration  version 5.0R2.4; system {     host-name Chicago;     login {         class superuser {             permissions all;         }         user lab {             uid 2000;             class superuser;             authentication {                 encrypted-password "lGdV/"; # SECRET-DATA Search for: bgp     bgp {         traceoptions {             file 539test4again2;             flag all;         }         local-address 2.2.2.2;         group IPV4_IBGP_ONLY {             type internal;             family inet {                 unicast;             }             family inet-vpn {                 unicast;             }             neighbor 4.4.4.4 {                 traceoptions {                     file vpntest;                     flag all;                 }             }         }     }     ospf { 


Juniper Networks Reference Guide. JUNOS Routing, Configuration, and Architecture
Juniper Networks Reference Guide: JUNOS Routing, Configuration, and Architecture: JUNOS Routing, Configuration, and Architecture
ISBN: 0201775921
EAN: 2147483647
Year: 2002
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net