I have been tasked with doing a survey and inventory of a very large network. I specifically need to get the serial numbers of 1000+ Avaya switches and routers. All are accessible via either telnet or ssh from my workstation. Almost all of them are accessible with the same user name and password. Some will have only telnet access and some will have only ssh access.
Once logged in, I can get the serial number like this:
en[crlf] (to enable cli command mode)
show tec[crlf] (returns technical information of device)
[3x spacebar] (to make sure serial number is displayed)
q (to stop displaying more data and return to
exit[crlf] (to end the terminal session)
From the output generated by that I can then grep the serial numbers.
So my problem is automating this in a bash script or something similar to generate a list of serial numbers against the given IP addresses of the devices.
The script should ideally:
1.Read the IP address of the device from a file.
2.Try to login with ssh credentials 1 (if failed, try credentials 2)
3.If failed, telnet credentials 1 (if failed, try credentials 2)
4.If all failed, write "Failed to login" to output file.
5.If successful, write device IP address and serial to output file.
6.Repeat for next device IP in list.
7.Using plain text username and passwords in this situation is not an issue.
I am using the latest Ubuntu Linux on my workstation.
Hoping someone can give me some advice on accomplishing this task. I do not look forward to manually logging into 1000 switches.