So here is the deal. I just went through a 5 day Python 3.x programming course and I'm trying to build off of my basic syntax knowledge. My first project is going to be how to use OS level commands and specifically ping a router and get the IP address and Interface description from a router/switch configuration file.I am *NOT* asking or wanting anyone to do this for me. I am just kinda lost as to how I would approach this project. Here is how I think this script would work and I would love feedback as I figure this out.Create a txt file with the IP addresses I want to pinginsert into a list within python... list = [name,ip,password]Use a while loop to complete the following ping function : ping function (no idea, still trying to find one online) If no response or the IP starts with 127.0, print "No response" else print (results)

The idea of this program is just to get my feet wet with Python in the networking realm. I would love if someone could hint me in the right direction, but please don't do it for me.

If you are on *NIX or Mac (probably on Windows too although I am not sure), you can simply a) run the 'ping' command, b) capture its output and c) parse it (use subprocess module for a), b)). Particular command line options for ping (e.g. only run once) that you need to use depend on your OS.I have no idea why you mention "password" : ping just sends "echo" on ICMP.

==> Write a function that does what you want with a single IP; post it here; then we could help you more with loops, lists, files etc.

Hello there,I guess it is quite late to reply to this,, still anyways, I can provide you the hint about how to get configuration files from router/switch.You'll have to use a module "PEXPECT" in your script. I had made a successful FTP automated script for logging in and getting a file. But never tried it on router or switch.If you need more light on this, mail me at marc_kriss at yahoo dot com .Will be happy to code together.

Cheers

Last edited by stranac on Mon May 19, 2014 9:18 am, edited 1 time in total.
Reason:First post lock.