I was recently faced with the task that a lot of experienced network admins have to deal with — being able to execute multiple commands on a router/switch, but commands that may temporarily break connectivity to said device as each line is pasted.

In the past…

Traditionally, one would achieve this “device-side chained execution” by using TFTP, as the “script” is only executed once uploaded to the device.  Conceptually, this is the same as being able to chain multiple commands at a Unix shell prompt, delimiting them with a semicolon.

Why oh why, silly auto-negotiate?!?

My example of needing to do this lately was to remotely change an interface’s speed and duplex — commands that typically knock ones telnet/ssh out for a period of time, or completely.  They were both set to auto, but was ethernet on one side, and gigabit ethernet on the other… whicih is always a major fail in autonegotiation land.

Of course, the seasoned router guy, purely by habit, will schedule a “reload in” just in case, but in their rare wisdom, Cisco brought the wonderfully-underrated language Tcl to their codebase.

Well hello, Tcl!

I’ve got a long and wonderous history with Tcl, and it’s graphical partner, Tk.  I forgot Tcl was available on more recent IOSs.  After some googling, I found though that a lot of sites didn’t talk about using it for remote work, where you need the classic chaining of commands.

Enough jabbering on.  This is how I used it for the speed and duplex change:

router#tclsh
router(tcl)#ios_config "interface gi0/1" "speed 100" "duplex full"
router(tcl)#

You may even want to combine that with a “reload in” 😉