Chapter 8
Writing CLI Macros
An E Series router has an embedded macro language that enables you to define and
run macros that can generate and execute CLI commands. Macro files—identified
by the .mac extension—can be used to store more than one macro. Depending on
your needs, you might want to store all of your macros in one file, group macros by
function, or store only one macro per file.
This chapter contains the following sections:
■ Platform Considerations on page 473
■ Writing Macros on page 473
■ Detecting and Recording Macro Errors on page 491
■ Running Macros on page 496
■ Scheduling Macros on page 499
■ Practical Examples on page 502
Platform Considerations
Macros are supported on all E Series routers.
For information about the modules supported on E Series routers:
■ See the ERX Module Guide for modules supported on ERX7xx models, ERX14xx
models, and the ERX310 Broadband Services Router.
■ See the E120 and E320 Module Guide for modules supported on the E120 and
E320 Broadband Services Routers.
Writing Macros
You must write macros on your computer, not on the E Series router. The macros
can contain loops, variables, string and numeric values, and conditional statements.
Macros can invoke other macros (as long as they are contained within the same
macro file), including themselves, but infinite recursion is not permitted. Macros are
case-insensitive.
Macros consist of control expressions and noncontrol expressions. Control expressions
are enclosed by control brackets, which are angle-bracket and number sign pairs, like
this: <# controlExpression #>. Examples of control expressions include the macro
Platform Considerations ■ 473