Macros
Macros, called smartport macros by Cisco, are groups of commands saved with reference names. Macros are useful when you find yourself entering the same group of commands repeatedly. For example, say you’re adding a lot of servers. Every time you add a server, you execute the same configuration commands for the switch interface to be used for that server. You could create a macro that would execute all of the commands automatically and then simply reference this macro every time you add a new server to the switch.
You create macros are created with the macro command. There are
two types of macros: global and
interface. An interface macro (the default type) is applied to one or
more interfaces. To make a macro global, include the global keyword when creating it.
The way macros are created is a little strange, because the commands
are not parsed as you enter them. As a result, you can enter invalid
commands without causing errors. First, enter the macro name macroname
command. Because you’re not including the global keyword, this will be an interface macro.
Then, enter the commands you’d like to include in the macro, one by one.
These commands are not checked for syntax. When you’re done entering
commands, put an at sign (@) on a line
by itself.
Here, I’ve created a macro named SetServerPorts. The commands
included are spanning-tree
portfast, hhhhhh (an invalid
command), and description <[ Server
]>:
3750(config)#macro name SetServerPorts Enter macro commands one per line. End with ...