Batch Cisco Configuration Script

I've seen a script a few years ago that would automate the configuration of many routers but now I cannot find it unfortunately. The way the script would work is as follows. I can't use Kiwi Cat Tools because I have more than 5 devices and no budget for this project and also I would really like to use this from unix.

The user would create the items to be placed into the config exactly as you would type them if you were telnet/ssh in (including any no commands if needed). You would place these commands into a plain text file with the filename being the device hostname/ip. When you ran the script you would pass it a directory and the script would telnet to each device (obtained from the filename) then send that file to the open telnet session.

tFTP isn't an option for me as this is a lab environment with no access other than a termserv. I cannot put the configs on a file server / router in the lab as there isn't always connectivity to all devices. The only constant access to the devices is telnetting to a termserv. Security isn't a concern either.

Google isn't giving me any love on this one and I'm trying to avoid recreating the will using Net::Telnet[::Cisco] if I don't have to.

Reply to
Paul Thomas
Loading thread data ...

Paul Thomas a écrit :

IIRC, it could be "CiscoT", that you can find here:

ftp://ftp.ripe.net/pride/tools/contrib.tar.gz

Hope this helps.

Reply to
Christophe Fillot

Thanks for the prompt reply but that's not what I was looking for. Here is an example.

The following files are in /tmp/cisco/changes cat host1 conf t no ip access-list 10 ip access-list 10 permit ip any any end wr me

## cat host2 conf t no ip access-list 10 ip access-list 10 permit ip any any end wr me

I would then type 'pushchanges /tmp/cisco/changes' and it would log into routers, enter enable mode, then cat the text to the telnet session. I made up the name pushchanges and I have no idea what language that script was written in.

I expect I'll be writing some perl to do this but just trying not to re-invent the wheel....especially since I'm not a fast (or good) programmer.

Reply to
Paul Thomas

We use an expect script to do this kind of thing, but I'd be slightly embarrassed to pass it on. (And I didn't write it, though that's not a boast that I'd have done any better.)

Sam

Reply to
Sam Wilson

Paul,

Here follow a simple example of a expect script. It only logs into the router and then give the prompt back to the user (that is what the interact command does). You pass the IP of target as parameter (scriptname.exp 10.10.10.10).

But you can improve it to send the strings you need... 'send' command simulates a user typing and 'expect' waits for that string... well, I suggest you reading the Expect/Tcl docs so you can pass parameters to the script.

the script:

-------------------- #!/usr/local/bin/expect

spawn telnet $argv

expect "Username:" send "johndoe\\r"

expect "Password:" send "secret\\r"

expect "\\>" send "en\\r"

expect "Password:" send "zekret\\r"

interact

--------------------

Regards, Adriano

Reply to
Adriano Prado

Cabling-Design.com Forums website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.