Capturing Output Of Commands; Adding Regular Expression Matching To Macros - Juniper JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04 Configuration Manual

Software for e series broadband services routers system basics configuration guide
Hide thumbs Also See for JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04:
Table of Contents

Advertisement

JunosE 11.3.x System Basics Configuration Guide

Capturing Output of Commands

Adding Regular Expression Matching to Macros

462
Macro language commands can start and stop the capture of JunosE command output
and save the results.
The env.startCommandResults command starts JunosE output capture and flushes any
existing capture buffer. The capture stops when directed by a stop command or when
the buffer maximum of 5,242,880 (5MB) characters is reached. The command output
in the buffer is stored as normally seen on the terminal output. A <CR> ends a line of
buffer data.
The env.stopCommandResults command stops JunosE output captures. The
env.getResults command obtains one line of output from the capture buffer.
The env.startCommandResults, env.stopCommandResults, and env.getResults
commands apply to one CLI session. There is no effect on CLI sessions other than the
CLI session running the macro.
The env.getResults command gets the next line of the capture buffer. Each call gets the
next line of the capture buffer. The command returns the first line the first time it is called
after a capture start (env.startCommandResults). It resets the next line it returns by
passing a line number argument. An argument of 0 or 1 returns the first line.
For example:
<# env.startCommandResults #>
show version
<# env.stopCommandResults #>
! possibly other JunosE commands
<# while something is true #>
<# outputLine := env.getResults #>
. . .
<# endwhile #>
Use the following syntax to check a string against a regular expression:
env.regexpMatch(stringToMatch, someRegularExpression)
For example, the string outputLine is checked to determine whether it starts with the
value System:
<# if env.regexpMatch(outputLine, "^System") #>
. . .
<# endif #>
In this example, the string interface is checked to determine whether it has the correct
syntax:
<# interface := env.argv(1) #>
<# if env.regexpMatch(interface, "^[0-9]+/[0-9]+$") #>
. . .
<# endif #>
Copyright © 2010, Juniper Networks, Inc.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the JUNOSE SOFTWARE FOR E SERIES 11.3.X - SYSTEM BASICS CONFIGURATION GUIDE 2010-10-04 and is the answer not in the manual?

This manual is also suitable for:

Junose 11.3

Table of Contents