Using XPath predicate expressions
In this recipe, we'll build on our previous op script, show-int.slax
, and enhance its functionality so that it can limit the output based on characteristics of the interface. To illustrate the capabilities of XPath predicates, we'll filter some of the annoying internal interfaces that showed up in the output of the previous recipe.
Getting started
In order to complete this recipe, you'll need access to a JUNOS router running with a basic configuration. Ideally, build upon the previous recipe and modify the source code.
How to do it...
The steps for the recipe are as follows:
- Start with the
show-int.slax
source code from the previous recipe, but use the new filenameshow-int-xpath.slax
. - Modify the
for-each
control statement and make use of an XPath predicate in order to hone in the scope of the selected range of items. The following are some examples:
- Only include Gigabit Ethernet interfaces:
for-each ($result// logical-interface[starts...