ping multiple Ips with python
dhostetler at sopris.net
Tue Jan 7 00:45:07 CET 2003
Andrew McGregor <andrew at indranet.co.nz> wrote in message news:<mailman.1041767229.6505.python-list at python.org>...
> I wasn't sure at a first glance if it did work. Now I go back and look,
> I'm sure it does.
> --On Sunday, January 05, 2003 00:21:07 +0000 darrell <dgallion1 at yahoo.com>
> > Didn't mess with the checksum since it works and it's fast enough.
> > The pyrex code was cool to look at.
> Thanks. I was just trying to learn pyrex, but since it's also around 30x
> faster, I'm going to keep it :-)
Thanks for your response and suggestions - although i'm still having
issues with the code.
*although "p" vs. "P" did get rid of the intital error.
I looked into other multithreaded examples on the web and came up with
import threading, os
def __init__(self, address, *args, **kwargs):
self.address = address
threading.Thread.__init__(self, *args, **kwargs)
pingCard = "ping -n 10 " + self.address
child = os.popen(pingCard).readlines()
if __name__ == '__main__':
PingList = ["127.0.0.1", "126.96.36.199", "188.8.131.52"]
threadList = 
# Create threads
for i in PingList :
# Start all threads
for thread in threadList:
when run through idle, the python shell hangs after all the ips
respond. Do I have to stop each thread individually after it executes
the ping command? other than that it seems to work....
More information about the Python-list