ping multiple Ips with python

.d.hos dhostetler at
Tue Jan 7 00:45:07 CET 2003

Andrew McGregor <andrew at> wrote in message news:<mailman.1041767229.6505.python-list at>...
> I wasn't sure at a first glance if it did work.  Now I go back and look, 
> I'm sure it does.
> Andrew
> --On Sunday, January 05, 2003 00:21:07 +0000 darrell <dgallion1 at> 
> wrote:
> > 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 :-)
> Andrew

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
the following:

import threading, os

def log(s):
    print s

class Pinger(threading.Thread):
    def __init__(self, address, *args, **kwargs):
        self.address = address       
        threading.Thread.__init__(self, *args, **kwargs)        

    def run(self):
        pingCard = "ping -n 10 " + self.address
        child = os.popen(pingCard).readlines()

if __name__ == '__main__':
    PingList = ["", "", ""]
    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....

thanks again

More information about the Python-list mailing list