05-14-2012 05:59 AM
I'm quite new to EEM, so please bear with me.
How can I handle interactive CLI commands. I want a script that detects when a configuration change has been made, and then copies the running configuration to a TFTP server. This is what I have tried:
event manager applet Configured
event syslog pattern ".*%SYS-5-CONFIG_I.*"
action 10 cli command "enable"
action 20 cli command "copy run tftp"
action 30 gets response
action 40 puts "MyTFTPServer"
action 50 gets response
action 60 puts "MyRtr.run"
action 70 end
All that happens is:
No. Job Id Proc Status Time of Event Event Type Name
1 1 Actv abort Mon May14 13:53:35 2012 syslog applet: Configured
2 2 Actv abort Mon May14 13:53:46 2012 syslog applet: Configured
3 3 Actv abort Mon May14 14:01:32 2012 syslog applet: Configured
4 4 Actv abort Mon May14 14:02:11 2012 syslog applet: Configured
5 5 Actv abort Mon May14 14:05:01 2012 syslog applet: Configured
6 6 Actv abort Mon May14 14:06:18 2012 syslog applet: Configured
7 7 Actv abort Mon May14 14:08:49 2012 syslog applet: Configured
(You see how many times I have tried to get it working ;-) The problem seems to be the interactivity of the "copy run tftp" command.
Can someone give me some guidance please?
Kevin Dorrell
Luxembourg
05-14-2012 06:26 AM
OK, I got it
event manager applet Configured
event syslog pattern ".*%SYS-5-CONFIG_I."
action 10 cli command "enable"
action 20 cli command "copy run tftp" pattern "Address or name of remote host.*"
action 30 cli command "MyTFTPServer" pattern "Destination filename.*"
action 40 cli command "MyRtr.run"
Kevin Dorrell
Luxembourg
05-14-2012 08:50 AM
Yep, you got it. Just a hint, you don't need to be so complex with your patterns. All you need to do is match one bit of the prompt. So you could use "Address" and "Destination" as your prompt patterns.
03-17-2020 07:11 AM
Hi @Joe Clarke , Can we have double prompts for the same CLI?
something like the switchover CLI.
03-17-2020 09:33 AM
You can cascade as many cli actions and patterns as you want:
cli command "interactive command" pattern "are you sure"
cli command "y" pattern "really sure"
cli command "y" pattern "confirm"
cli command "y"
When you expect to get back the device prompt, then you stop adding "pattern".
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide