Reading a list of IP's and Pinging them

A forum for general discussion of the Python programming language.

Reading a list of IP's and Pinging them

Postby sudo » Thu Jul 17, 2014 9:33 pm

Hello all. First post here, thanks for having me. Getting started with Python and hoping to get some questions answered.

My first project is to create a list of IP addresses and ping them- showing the output. First I'm creating a list of IP's which I have below- but how do I pipe each IP address, one by one, into a ping command? Should I use a list?

Thanks!

Code: Select all
router = raw_input("router: ")
start = input("start of ip: ")
start = start - 1 # otherwise list starts +1 in my range
finish = input("end of ip: ")
import sys
while start < finish:
   start = start + 1
   print router,
   sys.stdout.softspace=0 #deletes auto spaces
   print start

OUTPUT:
router: 10.10.10.
start of ip: 1
end of ip: 6
10.10.10.1
10.10.10.2
10.10.10.3
10.10.10.4
10.10.10.5
10.10.10.6


For the ping I was planning to:
Code: Select all
import subprocess
subprocess.call(["ping"])
Last edited by Mekire on Fri Jul 18, 2014 12:01 am, edited 1 time in total.
Reason: First post lock.
sudo
 
Posts: 1
Joined: Thu Jul 17, 2014 9:06 pm

Return to General Discussions

Who is online

Users browsing this forum: micseydel and 3 guests