Knowledge Center Search


 

[SRX] Why does the console CLI not display the exact number of lines with the pipe (l) last option?

  [KB26690] Show KB Properties

  [KB26690] Hide KB Properties

Categories:
Knowledge Base ID: KB26690
Last Updated: 23 Oct 2013
Version: 2.0

Summary:

This article explains why the console CLI does not display the exact number of lines with the | last xxx option. The default screen width is 80 characters; if the output line exceeds 80 characters the line count will be off. A procedure is supplied for resetting the screen width, to accommodate longer output lines.

Problem or Goal:

In most of the CLI operation commands, the | last xxx option can be used to display the last xxx number of lines. However, in certain outputs of console CLI operation commands, the last option displays fewer number of lines than expected.

Cause:

This issue is due to the default console CLI screen-width, which is 80. This is the default screen width of the dump terminal. That is, the CLI will count one line, when the output stream contains 80 characters or a line feed control character is hit. If the output of CLI has a line that is longer than 80 characters, that line will be counted as two or more.

For example:

lab@srx210> show security flow session | last 5 | no-more   
  In: xxx.xxx.xxx.53/38890 --> xxx.xx.xxx.39/5222;tcp, If: fe-0/0/3.0, Pkts: 76, Bytes: 5337  <==== 92 char
  Out: xxx.xx.xxx.39/5222 --> xxx.xxx.xxx.51/27232;tcp, If: ge-0/0/1.0, Pkts: 74, Bytes: 5837 <==== 93 char
Total sessions: 33

The first and second lines contains 92 and 93 characters respectively; so these two lines will be counted as two each, which makes it a total of four.

Solution:

If the console is connected via a terminal emulation program and the screen width supports more than 80 characters, the default screen-width can be configured to the maximum characters that are supported by terminal emulation. So, the last option will display the correct number of lines.

The following example shows how to reset the screen width to accommodate longer output lines:

lab@srx210> set cli screen-width 147 
Screen width set to 147

lab@srx210> show cli | match screen-width 
CLI screen-width set to 147

lab@srx210> show security flow session |last 3 | no-more
  In: xxx.xx.xx.134/787 --> xx.xxx.xx.235/23553;icmp, If: ge-0/0/0.0, Pkts: 1, Bytes: 84
  Out: xx.xxx.xx.235/23553 --> xxx.xx.xx.134/787;icmp, If: .local..0, Pkts: 1, Bytes: 84
Total sessions: 8

Purpose:
Configuration
Defect
Implementation
Installation
Interoperability
Specifications
Troubleshooting

Related Links:

 

 

ASK THE KB

Question or KB ID:


 


 

 
Copyright© 1999-2012 Juniper Networks, Inc. All rights reserved.