05-12-2022 02:52 PM
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.
Solved! Go to Solution.
05-12-2022 04:03 PM
#show version | redirect ? thx!!
05-12-2022 03:30 PM
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
05-12-2022 03:32 PM
thx! I will take a look. I appreciate your help
05-12-2022 04:03 PM
#show version | redirect ? thx!!
05-12-2022 04:07 PM
glad that command was helpful..
05-12-2022 05:23 PM - edited 05-12-2022 07:01 PM
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
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide