ping multiple Ips with python

Andrew McGregor andrew at indranet.co.nz
Mon Jan 6 20:50:25 CET 2003


--On Monday, January 06, 2003 10:59:13 -0800 ".d.hos" 
<dhostetler at sopris.net> wrote:

> when I run the script, I get the following error:
>
> Exception in thread Thread-1:
> Traceback (most recent call last):
>   File "I:\Python22\lib\threading.py", line 408, in __bootstrap
>     self.run()
>   File "I:\Python22\multi_ping.py", line 22, in run
>     child = popen2.Popen3("ping -i %i %s 2>&1" % (PING_INTERVAL,
> self.address))
> AttributeError: 'module' object has no attribute 'Popen3'
>
> Then the script continues to loop printing out "in main loop". I'm
> asssuming that the script is waiting for a response from the Pinger()
> class, and continues to loop because Pinger() never finishes
> executing?
>
> any ideas?

>From the docs:

The only way to retrieve the return codes for the child processes is by 
using the poll() or wait() methods on the Popen3 and Popen4 classes; these 
are only available on Unix.

This text is ambiguous, but I think you're being bitten by the Popen3 class 
not being there, not the specified methods.  Try popen2.popen3 (not the 
lowercase p) instead and see what happens :-)

By the way, I've never seen a ping command that will ever output 'Host is 
down', so I don't think this is portable either...

Andrew





More information about the Python-list mailing list