Detecting Missing Macros - Juniper SYSTEM BASICS - CONFIGURATION GUIDE V 11.1.X Configuration Manual

System basics configuration guide software for e series broadband services routers
Table of Contents

Advertisement

Without the onError macro, the macro would indicate the invalid command, but it
would also continue with the rest of the configuration. When using the onError macro,
the macro stops when it encounters the invalid command.
Executing the macro that contains the onError macro, the output appears as follows:
host1# macro badExecCommandTest.mac badExecCommandMacro
Macro 'badExecCommandMacro' in file 'badExecCommandTest.mac' starting execution (Id: 101)
SUN JAN 08 2005 07:21:50 UTC
ERX-40-94-fb#foo
^
% Invalid input detected at '^' marker.
Privilege level is 15
Macro 'badExecCommandMacro' in file 'badExecCommandTest.mac' ending execution (Id: 101)
You can determine the execution progress through the runStatus result entry in the
macroData log file. For this example, the log output indicates the command error
and displays the following to indicate that the macro ended early:
runStatus is after foo
host1# show log data category macroData severity debug
NOTICE 01/08/2006 07:14:13 macroData: Macro 'startmin' in file 'master.mac' starting execution (Id: 1)
on vty, 0
NOTICE 01/08/2006 07:14:18 macroData: Macro 'startmin' in file 'master.mac' ending execution (Id: 1) on
vty, 0
NOTICE 01/08/2006 07:21:50 macroData: Macro 'badExecCommandMacro' in file 'badExecCommandTest.mac' starting
execution (Id: 101) on vty, 0
ERROR 01/08/2006 07:21:50 macroData: (Id: 101) Command error: foo, Command syntax error
NOTICE 01/08/2006 07:21:50 macroData: (Id: 101) commandError is foo
NOTICE 01/08/2006 07:21:50 macroData: (Id: 101) commandErrorStatus is Command syntax error
NOTICE 01/08/2006 07:21:50 macroData: (Id: 101) runStatus is after foo
NOTICE 01/08/2006 07:21:50 macroData: Macro 'badExecCommandMacro' in file 'badExecCommandTest.mac' ending
execution (Id: 101) on vty, 0

Detecting Missing Macros

In this example, the following macro file (badMacroInvocation.mac) is programmed
to invoke a missing or nonexistent macro (tmpl.foo).
When using the onError macro, the macro stops when it encounters the missing
macro. The output appears as follows:
<# badMacroInvocation #>
<# env.setResult("runStatus","start" ) #>
<# tmpl.foo #>
<# env.setResult("runStatus","complete" ) #>
<#endtmpl#>
<# onerror #>
<# errCmd := env.getErrorCommand #>
<# errStatus := env.getErrorStatus #>
<# env.setResult("commandError", errCmd) #>
<# env.setResult("commandErrorStatus", errStatus) #>
<#endtmpl#>
Chapter 8: Writing CLI Macros
Detecting and Recording Macro Errors
495

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junose 11.1

Table of Contents