yangli-pro and yp-shell support filtering and paginating of their output.


Pipe commands:

begin, include, exclude, display, and redirect, allow output to be filtered, formatted and redirected on a line-by-line basis. The commands can be combined.

  • begin, include, exclude: control what is and what is not displayed and where it begins
  • display: format the output. There are 3 values accepted:
    • xml : XML display mode
    • json: JSON display mode
    • curmode: current value of $$display-mode
  • redirect: send the resulting output to a text file rather than the screen


The output below shows yangcli-pro's display for netconfd-pro's /system/uname container, first in the normal (default) output and then with the "display xml" format applied:


john@localhost> sget /system/uname 

Filling container /system/uname:
RPC Data Reply 18 for session 18 [default]: 

rpc-reply {
  data {
    system {
      uname {
        sysname Linux
        release 4.4.0-104-generic
        version '#127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017'
        machine x86_64
        nodename linux-conf
      }
    }
  }
}


john@localhost> sget /system/uname | display xml 

Filling container /system/uname: 
RPC Data Reply 19 for session 18 [default]: 

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> 
  <data> 
    <system xmlns="http://netconfcentral.org/ns/yuma-system"> 
      <uname> 
        <sysname>Linux</sysname> 
        <release>4.4.0-104-generic</release> 
        <version>#127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017</version> 
        <machine>x86_64</machine> 
        <nodename>linux-conf</nodename> 
      </uname> 
    </system> 
  </data> 
</rpc-reply>


Next several pipe commands are combined. First the output is filtered so only lines that contain "name" are shown and then lines that contain "name" but exclude "node" are output:


john@localhost> sget /system/uname | display xml include name

Filling container /system/uname:      <uname>
        <sysname>Linux</sysname>
        <nodename>linux-conf</nodename>
      </uname>

john@localhost> sget /system/uname | display xml include name exclude node

Filling container /system/uname:      <uname>
        <sysname>Linux</sysname>
      </uname>


The output can be sent to a file rather than the display by using the "redirect" command:


john@localhost> sget /system/uname | display xml include name exclude node redirect ~/myoutput.xml

Filling container /system/uname:
john@localhost> quit

john@linux-conf ~$ cat myoutput.xml 
      <uname>
        <sysname>Linux</sysname>
      </uname>
john@linux-conf ~$ 




Pagination:
The "term-length" CLI parameter and variable set the number of lines to the output before pausing:

  • "Space" displays the next page
  • "Enter" displays the next line
  • "q" quits output


For more information see the "Controlling Terminal Output" section in the yangcli-pro Manual