Configuration backups using tcl -> ftp, typeahead problems

Answered Question
Feb 22nd, 2008
User Badges:

Hi all,


I am setting up automatic running-config backup schedule on a range of devices (2800 series, 800 series, Catalyst 4948). I'm doing the configuration backup via ftp. Copying files to ftp: filesystem is always interactive (IOS prompts for hostname and filename). As kron can't pass any input to commands it executes, the theoretical way round is to use tcl and typeahead. The problem is that typeahead simply doesn't seem to work for me. Software versions:

870: 12.4(4)T6, RELEASE SOFTWARE (fc2)

2800:Version 12.4(3h), RELEASE SOFTWARE (fc2)

2800:Version 12.4(3d), RELEASE SOFTWARE (fc3)

4948:Version 12.2(25)SG, RELEASE SOFTWARE (fc2)

So okay, on the Catalysts I can forget about tcl if I don't upgrade the software, but what about 12.4?


the tcl script is pretty simple:

...

typeahead "<ftp_server>"

typeahead $hostname

exec "copy running-config ftp://<ftp_server>/"


When I execute the script, console still waits for input, and the script executes when I tap enter twice like I did it straight from the CLI. Kron will fail when attempting to run this kind of script.


Is a software upgrade the only solution to make typeahead work as intended? If not, is SNMP the only way to copy the configs to a remote location? Or is SNMP "THE" way to do it?


Many thanks,

Wojciech Owczarek




Correct Answer by Joe Clarke about 9 years 5 months ago

Don't use TCL and kron (besides, you can't use typeahead outside of tclsh). The interaction is buggy at best. I see two solutions for you here. The first is to configure "file prompt quiet" on this device. Then the copy command should not be interactive. The second is to convert the kron policy to an Embedded Event Manager policy. This could be as simply as:


event manager applet copy_config

event timer cron cron-entry "0 * * * *"

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "file prompt quiet"

action 4.0 cli command "end"

action 5.0 cli command "copy runn ftp://..."

action 6.0 cli command "config t"

action 7.0 cli command "no file prompt quiet"

action 8.0 cli command "end"


Another alternative is to use EEM and TCL which will allow you to run interactive commands, and do more powerful scripting operations.


The downside of the EEM approaches is that they will not work on 12.2(25)SG. However, they will work on your other devices. The kron/file prompt quiet mechanism should work on all platforms.


If you want more details on EEM, see http://www.cisco.com/en/US/docs/ios/12_4t/netmgmt/configuration/guide/t_eemo.html .

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 4 (1 ratings)
Loading.
Correct Answer
Joe Clarke Fri, 02/22/2008 - 10:29
User Badges:
  • Cisco Employee,
  • Hall of Fame,

    Founding Member

Don't use TCL and kron (besides, you can't use typeahead outside of tclsh). The interaction is buggy at best. I see two solutions for you here. The first is to configure "file prompt quiet" on this device. Then the copy command should not be interactive. The second is to convert the kron policy to an Embedded Event Manager policy. This could be as simply as:


event manager applet copy_config

event timer cron cron-entry "0 * * * *"

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "file prompt quiet"

action 4.0 cli command "end"

action 5.0 cli command "copy runn ftp://..."

action 6.0 cli command "config t"

action 7.0 cli command "no file prompt quiet"

action 8.0 cli command "end"


Another alternative is to use EEM and TCL which will allow you to run interactive commands, and do more powerful scripting operations.


The downside of the EEM approaches is that they will not work on 12.2(25)SG. However, they will work on your other devices. The kron/file prompt quiet mechanism should work on all platforms.


If you want more details on EEM, see http://www.cisco.com/en/US/docs/ios/12_4t/netmgmt/configuration/guide/t_eemo.html .

wojciechowczarek Fri, 02/22/2008 - 10:51
User Badges:

Thanks a lot, the "file prompt quiet" option was what I needed, just didn't do enough research. Although, as I am currently using SNMP on all the devices, I think I will go for using SNMP. Both methods have pros and cons - with SNMP I can get all the configs with one run of a perl script, but not when the server dies, besides I will have to keep the RW community string in my script. With EEM/kron I will have to configure all the devices to back up the configuration files, but once configured, they will do it all for me.


Thanks again,

Wojciech

Actions

This Discussion