Is there a way to submit a batch of commands to a Cisco router and have them execute from the router?

I believe it's possible to copy a file from flash: to running-config, but I am not 100% sure. You may be better off copying the existing running-config to a known-good-startup, copying the config you want on top of startup-config, then reload the router (with, ideally, somneone on site who can be walked through a password-recovery-style recovery, should the new config be broken).

Alternatively, if the relevant config can be comfortably fit in a single TCP frame, you could write some code to issue a reload in 10 command, then a config t and finish off with all relevant config commands, separated by CR NL, in a single frame.

Edit: Then either log on to the router manually or send a second frame with enough commands in it to cancel the reload (the relevant IOS command is reload cancel).


You can do this with a tclsh macro.

Create macro

router#tclsh
router(tcl)# set foo {
+>conf t
+>int f0/1
+>ip addr.....
+>no ip route 0.0.0.0 .....
+>ip route 0.0.0.0 .....
+>exit  
+>exit  
+>}     

Execute and quit tclsh:

router(tcl)#eval $foo
...
router(tcl)#tclq

Test this in a lab to make yourself familiar with tclsh in Cisco routers.