Retrieving device serial number from Cisco switch
Tiam-Abderezai opened this issue · 4 comments
I want my script to 1) login to a Cisco switch and do a "show inventory" command (done successfully so far) 2) save the output of "SN: FOCxxxxxxxx" in memory instead of saving it to a local file.
I want to do this in order to be able to match each serial number to a particular IP address.
Any ideas what I can do to achieve this?
Thanks!
Tiam
I just added a script to this repo that does what you want with RESTCONF. You could use that as a model for CLI commands if you wanted. See the new RC-get-serial-numbers directory in this repo.
@xorrkaz Thank you!!!!!
I made a script that does that just in case anyone is interested. You can find it here.
Not all Cisco serial numbers will start with FOC. You might try this for your pattern:
regexoutput = re.search('SN:\s+(\w\d+)', output)
print(regexoutput.group(1))