Showing results for 
Search instead for 
Did you mean: 

Interactive CLI commands

Kevin Dorrell
Level 10
Level 10

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 ""

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


4 Replies 4

Kevin Dorrell
Level 10
Level 10

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 ""

Kevin Dorrell


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.

Hi @Joe Clarke , Can we have double prompts for the same CLI?

something like the switchover CLI.

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".