O'Reilly logo

JUNOS Automation Cookbook by Adam Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

The steps for the recipe are as follows:

  1. Start with the show-int.slax source code from the previous recipe, but use the new filename show-int-xpath.slax.
  2. 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-with(name, "ge-")]               ) {
    • Only include loopback interfaces, if they are indexed with 0—ignore all others:
                for-each ($result//                  logical-interface[!starts-with(name, "lo0") ||                                              name=="lo0.0"]) {
  1. Copy the script to the JUNOS router—both routing engines if necessary—and configure the script as a system op script: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required