JunosE 11.3.x System Basics Configuration Guide
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)
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
480
<# env.setResult("runStatus","after show privilege" ) #>
show clock
<# env.setResult("runStatus","complete" ) #>
<#endtmpl#>
<# onerror #>
<# errCmd := env.getErrorCommand #>
<# errStatus := env.getErrorStatus #>
<# env.setResult("commandError", errCmd) #>
<# env.setResult("commandErrorStatus", errStatus) #>
<#endtmpl#>
If the macro were to run to completion, the following commands would be executed:
show clock
foo
show privilege
show clock
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:
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
Detecting Missing Macros
In this example, the following macro file (badMacroInvocation.mac) is programmed to
invoke a missing or nonexistent macro (tmpl.foo).
<# badMacroInvocation #>
Copyright © 2010, Juniper Networks, Inc.
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?
Questions and answers