cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2254
Views
0
Helpful
3
Replies

Scripting Cisco Switches

parklabel
Level 1
Level 1

I'm trying to run a script to backup configs from Cisco switches with SSH and I can't seem to run a loop with the username/password saved for the session.

I'm using Teraterm macro at this time.

Anyone has any suggestions or examples? I'll post my config if anyone's interested.

Thanks.

3 Replies 3

Joe Clarke
Cisco Employee
Cisco Employee

I don't have any experience with TeraTerm macros, but I do have expect experience. How do you need to backup the configs (i.e. TFTP, simple screen scrape, etc.)? What switches running what IOS/CatOS?

For starters, I'm just trying to backup the configs (sh run, sh ver) from a couple of 6509 switches (IOS 12.2(18)). I'll have about 80-90 devices in a bit.

Another setback is that I don't have admin rights (yeah, I know) and I've only been able to use TeraTerm for scripting so far. I wish Putty had this feature.

Thank you.

Here is an expect script that will do what you want. It can be made to work on Windows provided you have expect for Windows (http://expect.nist.gov/) and OpenSSH for Windows (http://sshwindows.sourceforge.net/). It relies on a creds.txt file to exist in %HOME% (you may need to set this variable prior to running the script). For example, if you stick the script in C:\TEMP, create a C:\TEMP\creds.txt with:

username=parklabel

password=parklabel123

enable=enable123

Then:

set HOME=C:\TEMP

expect C:\TEMP\config_backup.exp 10.1.1.1

(Where 10.1.1.1 is the address of the switch).

This will create two files in C:\TEMP: 10.1.1.1.cfg and 10.1.1.1.ver.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: