![Juniper JUNOSE 11.3 Configuration Manual Download Page 509](http://html1.mh-extra.com/html/juniper/junose-11-3/junose-11-3_configuration-manual_2032852509.webp)
<# endwhile #>
<# env.setResult("runStatus","complete" ) #>
<#endtmpl#>
<# onError #>
<# env.setResult("commandError", env.getErrorCommand) #>
<# env.setResult("commandErrorStatus", env.getErrorStatus) #>
<#endtmpl#>
If the macro were to run to completion, the CLI would execute the commands as follows:
interface fastEthernet 500
interface fastEthernet 499
.
.
.
interface fastEthernet 1
Because the macro uses invalid interface formats, executing the macro without the
embedded onError macro would result in error output for each loop. However, the onError
macro detects the error and stops the macro. Using the onError macro, the output appears
as follows:
host1(config)#
macro testInterfaceCommand.mac badInterfaceCommandMacro
Macro 'badInterfaceCommandMacro' in file 'testInterfaceCommand.mac' starting execution (Id: 402)
Enter configuration commands, one per line. End with ^Z.
ERX-40-94-fb(config)#interface fastEthernet 500
^
% invalid interface format
Macro 'badInterfaceCommandMacro' in file 'testInterfaceCommand.mac' ending execution (Id: 402)
You can determine the execution progress through the runStatus result entry in the
macroData log file. For this example, the runStatus value of 500 indicates that the macro
ended early.
host1(config)#
show log data category macroData severity debug
NOTICE 01/07/2006 09:46:57 macroData: Macro 'badInterfaceCommandMacro' in file 'testInterfaceCommand.mac'
starting execution (Id: 402) on vty, 0
ERROR 01/07/2006 09:46:57 macroData: (Id: 402) Command error: interface fastEthernet 500, Command execution
error
NOTICE 01/07/2006 09:46:57 macroData: (Id: 402) commandError is interface fastEthernet 500
NOTICE 01/07/2006 09:46:57 macroData: (Id: 402) commandErrorStatus is Command execution error
NOTICE 01/07/2006 09:46:57 macroData: (Id: 402) runStatus is Loop:500
NOTICE 01/07/2006 09:46:57 macroData: Macro 'badInterfaceCommandMacro' in file 'testInterfaceCommand.mac'
ending execution (Id: 402) on vty, 0
Detecting Invalid Commands
In this example, the following macro file (
badExecCommand.mac
) is programmed to
executes four exec mode commands. However, the second command in the sequence
is invalid.
<# badExecCommandMacro #>
<# env.setResult("runStatus","start" ) #>
show clock
<# env.setResult("runStatus","after first show clock" ) #>
foo
<# env.setResult("runStatus","after foo" ) #>
show privilege
479
Copyright © 2010, Juniper Networks, Inc.
Chapter 8: Writing CLI Macros
Summary of Contents for JUNOSE 11.3
Page 6: ...Copyright 2010 Juniper Networks Inc vi...
Page 8: ...Copyright 2010 Juniper Networks Inc viii JunosE 11 3 x System Basics Configuration Guide...
Page 24: ...Copyright 2010 Juniper Networks Inc xxiv JunosE 11 3 x System Basics Configuration Guide...
Page 32: ...Copyright 2010 Juniper Networks Inc 2 JunosE 11 3 x System Basics Configuration Guide...
Page 146: ...Copyright 2010 Juniper Networks Inc 116 JunosE 11 3 x System Basics Configuration Guide...
Page 166: ...Copyright 2010 Juniper Networks Inc 136 JunosE 11 3 x System Basics Configuration Guide...
Page 432: ...Copyright 2010 Juniper Networks Inc 402 JunosE 11 3 x System Basics Configuration Guide...
Page 488: ...Copyright 2010 Juniper Networks Inc 458 JunosE 11 3 x System Basics Configuration Guide...
Page 524: ...Copyright 2010 Juniper Networks Inc 494 JunosE 11 3 x System Basics Configuration Guide...
Page 554: ...Copyright 2010 Juniper Networks Inc 524 JunosE 11 3 x System Basics Configuration Guide...
Page 566: ...Copyright 2010 Juniper Networks Inc 536 JunosE 11 3 x System Basics Configuration Guide...
Page 588: ...Copyright 2010 Juniper Networks Inc 558 JunosE 11 3 x System Basics Configuration Guide...
Page 613: ...PART 3 Index Index on page 585 583 Copyright 2010 Juniper Networks Inc...
Page 614: ...Copyright 2010 Juniper Networks Inc 584 JunosE 11 3 x System Basics Configuration Guide...
Page 632: ...Copyright 2010 Juniper Networks Inc 602 JunosE 11 3 x System Basics Configuration Guide...