cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1180
Views
5
Helpful
5
Replies

get as much info out of 50 cisco devices

mathew43
Level 1
Level 1

 I need to get as much info out of 50 cisco devices.

I have a TFTP server going, I have been running this command copy running-config TFTP://10.10.10.10/filename.txt 

Which is great, but I need more info.  I need the info in Show Version (copy show version to TFTP doesn't work) 

 

Also is there a way to use the command copy running-config TFTP://10.10.10.10/%hostname%.txt 

 

%hostname% meaning saving the file as the hostname automatically, so I don't have to type in 50 hostname when exporting to TFTP 

thx for any help.  

1 Accepted Solution

Accepted Solutions

#show version | redirect ?  thx!! 

View solution in original post

5 Replies 5

balaji.bandi
Hall of Fame
Hall of Fame

You can do a simple automated backup script to backup all devices with device names:

 

https://github.com/AlexMunoz905/Python-Cisco-Backup

 

I need the info in Show Version (copy show version to TFTP doesn't work) 

 

#show version | redirect ?
flash0: Uniform Resource Locator
flash1: Uniform Resource Locator
flash2: Uniform Resource Locator
flash3: Uniform Resource Locator
flash: Uniform Resource Locator
ftp: Uniform Resource Locator
http: Uniform Resource Locator
https: Uniform Resource Locator
nvram: Uniform Resource Locator
rcp: Uniform Resource Locator
scp: Uniform Resource Locator
tftp: Uniform Resource Locator

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

thx! I will take a look.  I appreciate your help 

#show version | redirect ?  thx!! 

glad that command was helpful..

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

nice code!  Just a nitpicky suggestion, but you should be using a context manager for writing to files.... instead of

    fileName = hostname + "_" + dt_string
    # Creates the text file in the backup-config folder with the special name, and writes to it.
    backupFile = open("backup-config/" + fileName + ".txt", "w+")
    backupFile.write(output)
    print("Outputted to " + fileName + ".txt!")

I would use:

    fileName = f"backup-config/{hostname}_{dt_string}.txt"
    with open(fileName, "w+") as backupFile:
    backupFile.write(output)
    print("Outputted to " + fileName + ".txt!")

There are several benefits to using a context manager, but most importantly, without a backupFile.close() call, the file stays open.  Also, f-strings are your friend!!!  They seem foreign at first, but with a little practice they really clean up the code and make it easier to read.  Just my 2 cents... Keep grinding

Review Cisco Networking for a $25 gift card