Intercept Cisco’s “write net” command with EEM

Posted by: admin  :  Category: Cisco, Networking

Well, here’s just a quick snippet on how to intercept Cisco’s “write net” command.

Why would I want to do it? Because people are lazy and tend to forget.
So instead of forcing them to remember, that they need to add the ‘/incoming’ directory for config writebacks,
I just let an EEM applet do the trick.

How is it working?

The EEM applet is intercepting the ‘write net’ cli command by matching all inputs against the pattern given.
Whenever the command is seen, it will run my own commands instead. Nice, huh? ;-?

Enough talking, here’s the code:

no event manager applet WRITENET
event manager applet WRITENET
event cli pattern “write net” sync yes
action 1.0 puts “Please wait …”
action 1.5 cli command “enable”
action 2.0 cli command “conf t”
action 2.1 cli command “file prompt quiet”
action 2.2 cli command “exit”
action 3.0 cli command “copy run tftp://tftp01/incoming/”
action 4.0 cli command “conf t”
action 4.1 cli command “no file prompt quiet”
action 4.2 cli command “exit”
action 5.0 puts “Copy stored to TFTP server at /incoming, good bye”

Comments are closed.