Router Interface script

Router Interface script

Postby Saidin3693 » Sat Dec 07, 2013 10:06 pm

Hey everyone,

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 ping
insert 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.
Last edited by Yoriz on Sat Dec 07, 2013 11:57 pm, edited 1 time in total.
Reason: First post lock
Saidin3693
 
Posts: 1
Joined: Sat Dec 07, 2013 9:55 pm

Re: Router Interface script

Postby ochichinyezaboombwa » Mon Dec 09, 2013 7:56 pm

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.
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm

Re: Router Interface script

Postby kriss332 » Sun May 18, 2014 6:59 am

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.
kriss332
 
Posts: 2
Joined: Sun May 18, 2014 6:50 am


Return to Networking

Who is online

Users browsing this forum: No registered users and 2 guests