View the ‘show’ output from multiple devices using Python

Traditionally, us Network Engineers have had to live at the mercy of the command line for performing pretty much any task in our day-to-day work lives. Let’s say for example, that you want to verify the routing table of a couple routers. Conventional wisdom tells us that to accomplish that, we need to login to each router over SSH using a terminal emulator like Putty and type ‘show ip route’.  Easy stuff! What if, instead of a couple routers, you have to do that on 10 routers… or how about a 100?  You are likely to spend the next couple hours doing just that… login, check output, repeat!

Well, turns out that there is a much easier way to get that accomplished.

Below is a relatively simple Python script which you can use to view the ‘show’ outputs of  devices like Routers and Switches and comprising of a range of vendors. You don’t have to be an expert at using Python; just the ability to run a Python code is more than sufficient. The whole idea is to use a Python module called ‘paramiko’, which establishes an SSH session with the network devices and iterates over each device to obtain the show output. If that sounds a little bit confusing, no worries at all. All you have to do is replace the list ‘routers’ with your device hostnames and the username and password in the script. That’s it! Running the program will give you outputs of all the devices in the list one below the other. It doesn’t matter if you have 10 devices or 1000. You just have to run the script once.  Once the script is run, Python will ask you to enter a command. At this point, enter the show command you want to use, like ‘show ip route’ or ‘show clock’.



You can check out this code on my Github page as well at

Let’s admit that Networking has been relatively stagnant over the last 2 decades, while things like server and storage administration have seen monumental advancements. However, with the advent of things like SDN, APIs, config management tools, etc. there been a meteoric rise in Network Automation in the past few years . Let’s hope that these advancements continue, along with our rate of innovation, so Networking can catch up with other technologies soon!

Leave a Reply

Your email address will not be published. Required fields are marked *