Detectable Macro Errors
CLI macros detect various errors when a macro is executed. Some of these errors are
detected without the use of an onError macro; they include the following:
•
Macro file not found
•
Macro not found
•
Macro compilation error
•
Macro does not complete error due to excessive looping or recursion
The following errors are detected only when a CLI macro file contains an onError macro:
•
Syntactic error in executed CLI command
•
Runtime error in executed CLI command
In addition to these detectable errors, you can use the following environment commands
to return textual error information to the macroData log file:
•
env.getErrorCommand
•
env.getErrorStatus
CAUTION:
Though you can use the
env.getErrorCommand
and
env.getErrorStatus
commands in any macro, the only appropriate place
from which to execute these commands is from an onError macro.
Logging Macro Results
You can use the
env.setResult
command to set parameters within a macro to display
information through the macroData log file. When defined, parameter information appears
in the macroData log file at the NOTICE severity level following the completion of the
macro.
The following example defines several results (1 through 5):
<# numberMacro #>
<# env.setResult("A", “ “ $1 ) #>
<# env.setResult("A", “ “ $2 ) #>
<# env.setResult("A", “ “ $3 ) #>
<# env.setResult("A", “ “ $4 ) #>
<# env.setResult("A", “ “ $5 ) #>
<#endtmpl#>
Each value is sent to the macroData log file, starting with 1 and ending with 5. Each
successive value overwrites the previous value in the log file. In other words, if the macro
ends after setting the third result (that is, 3) the log file displays the following:
A is 3
If the macro finishes completely, the log file displays the following:
477
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...