[Contents] [Prev] [Next] [Index] [Report an Error]

Capturing Output of Commands

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 stopcommand 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 #>

[Contents] [Prev] [Next] [Index] [Report an Error]