Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

How to transform simple Tcl script into EEM policy?

I have the following simple Tcl script which can be executed from CLI using command "tclsh filename.tcl":

# --- start of script ---

typeahead "\n\n"
exec copy nvram://startup-config ftp://username:password@10.1.1.1/backup-confg

# --- end of script ---

Now I would like to turn it into EEM policy which will copy startup-config to FTP server each time user types in command "copy running-config startup-config". I created directory flash://tcl/, copied my script there and entered these commands:

event manager directory user policy flash://tcl/

event manager applet archive

  event cli occurs 1 sync no pattern "copy running-config startup-config"

How should I complete my configuration and how should I change my script?

Thanks in advance!

4 REPLIES
Cisco Employee

Re: How to transform simple Tcl script into EEM policy?

You don't need your Tcl script anymore, nor do you need the event manager directory user policy command.  This applet should do what you want:

event manager applet archive

event cli pattern "copy running-config startup-config" sync no

action 1.0 cli command "enable"

action 2.0 cli command "copy start ftp://username:password@10.1.1.1/backup-config" pattern "Address"

action 3.0 cli command "10.1.1.1" pattern "Destination"

action 4.0 cli command "backup-config"

New Member

Re: How to transform simple Tcl script into EEM policy?

Thank you very much.

I'll try this solution as soon as it's possible.

New Member

Re: How to transform simple Tcl script into EEM policy?

Thank you once again, Joseph.

Your appllet has solved my problem, although I had to customise it a little to make it work on my router Cisco 2851 (IOS Version 12.4(18)):

event manager applet archive  
  event cli pattern "copy running-config startup-config" sync no skip no occurs 1
  action 1.0 syslog priority notification msg "Trying to upload running-config to FTP server..."
  action 2.0 cli command "enable"
  action 3.0 cli command "configure terminal"
  action 3.2 cli command "file prompt quiet"
  action 3.4 cli command "end"
  action 4.0 cli command "copy startup-config ftp://user:password@10.1.1.1/backup-config"
  action 5.0 cli command "configure terminal"
  action 5.2 cli command "no file prompt quiet"
  action 5.4 cli command "end"
Cisco Employee

Re: How to transform simple Tcl script into EEM policy?

You have EEM 2.1.  The ability to do interactive commands in applets was added in EEM 2.3.  You would either need to use an EEM Tcl policy, or do what you've done and configure "file prompt quiet".

576
Views
4
Helpful
4
Replies