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:
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?
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 .