<# 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#>
When using the onError macro, the macro stops when it encounters the missing macro.
The output appears as follows:
host1#
macro badMacroInvocation.mac badMacroInvocation
Macro 'badMacroInvocation' in file 'badMacroInvocation.mac' starting execution (Id: 407)
% can't find macro foo
Macro 'badMacroInvocation' in file 'badMacroInvocation.mac' ending execution (Id: 407)
You can determine the execution progress through the runStatus result entry in the
macroData log file. For this example, the log output indicates the macro error and displays
the following to indicate that the macro ended prior to invoking the macro:
start
host1#
show log data category macrodata severity debug
NOTICE 05/27/2005 12:39:10 macroData: Macro 'badMacroInvocation' in file 'badMacroInvocation.mac' starting
execution (Id: 407) on vty, 0
ERROR 05/27/2005 12:39:10 macroData: (Id: 407) Command error: foo, macro not found
NOTICE 05/27/2005 12:39:10 macroData: (Id: 407) commandError is foo
NOTICE 05/27/2005 12:39:10 macroData: (Id: 407) commandErrorStatus is macro not found
NOTICE 05/27/2005 12:39:10 macroData: (Id: 407) runStatus is start
NOTICE 05/27/2005 12:39:10 macroData: Macro 'badMacroInvocation' in file 'badMacroInvocation.mac' ending
execution (Id: 407) on vty, 0
Running Macros
Although you must write macros on a computer, you can copy them to the system. Issue
the
macro
command from the CLI to execute both local macros and macros stored
remotely.
You can display the commands that are generated by the macro file without executing
the commands by using the
test
keyword. We recommend you confirm that the test
display matches your expectations before you execute the macro to run the commands.
You can terminate a macro while it is running by pressing Ctrl+c. You can close Telnet
and SSH windows while a macro is running, but the macro does not terminate until it
completes the current command.
macro
•
Use to execute a macro that generates—and can execute—CLI commands. This
command is available in all command modes.
•
This command invokes a hidden FTP client and takes place in the context of the current
virtual router (VR) rather than the default VR. You must configure the FTP server so
481
Copyright © 2010, Juniper Networks, Inc.
Chapter 8: Writing CLI Macros
Содержание JUNOSE 11.3
Страница 6: ...Copyright 2010 Juniper Networks Inc vi...
Страница 8: ...Copyright 2010 Juniper Networks Inc viii JunosE 11 3 x System Basics Configuration Guide...
Страница 24: ...Copyright 2010 Juniper Networks Inc xxiv JunosE 11 3 x System Basics Configuration Guide...
Страница 32: ...Copyright 2010 Juniper Networks Inc 2 JunosE 11 3 x System Basics Configuration Guide...
Страница 146: ...Copyright 2010 Juniper Networks Inc 116 JunosE 11 3 x System Basics Configuration Guide...
Страница 166: ...Copyright 2010 Juniper Networks Inc 136 JunosE 11 3 x System Basics Configuration Guide...
Страница 432: ...Copyright 2010 Juniper Networks Inc 402 JunosE 11 3 x System Basics Configuration Guide...
Страница 488: ...Copyright 2010 Juniper Networks Inc 458 JunosE 11 3 x System Basics Configuration Guide...
Страница 524: ...Copyright 2010 Juniper Networks Inc 494 JunosE 11 3 x System Basics Configuration Guide...
Страница 554: ...Copyright 2010 Juniper Networks Inc 524 JunosE 11 3 x System Basics Configuration Guide...
Страница 566: ...Copyright 2010 Juniper Networks Inc 536 JunosE 11 3 x System Basics Configuration Guide...
Страница 588: ...Copyright 2010 Juniper Networks Inc 558 JunosE 11 3 x System Basics Configuration Guide...
Страница 613: ...PART 3 Index Index on page 585 583 Copyright 2010 Juniper Networks Inc...
Страница 614: ...Copyright 2010 Juniper Networks Inc 584 JunosE 11 3 x System Basics Configuration Guide...
Страница 632: ...Copyright 2010 Juniper Networks Inc 602 JunosE 11 3 x System Basics Configuration Guide...