ping - statistics

A

Alberto Vera

Hello:

Is it possible to make "ping" from Python and get statistics like using command prompt from Windows?
How Can I capture them into variables?
Thanks



Pinging XXXX.XXXX.XXXX.XXXX with 32 bytes of data:

Reply from XXXX.XXXX.XXXX.XXXX: bytes=32 time<10ms TTL=255
Reply from XXXX.XXXX.XXXX.XXXX: bytes=32 time<10ms TTL=255
Reply from XXXX.XXXX.XXXX.XXXX: bytes=32 time<10ms TTL=255
Reply from XXXX.XXXX.XXXX.XXXX: bytes=32 time<10ms TTL=255

Ping statistics for XXXX.XXXX.XXXX.XXXX:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
 
P

Peter Hansen

Alberto said:
Is it possible to make "ping" from Python and get statistics like using command prompt from Windows?
How Can I capture them into variables?

The most direct approach for this kind of thing is often to use os.popen()
and the "re" module to execute the command and capture it's output, and
to parse the output to find the data of interest.

If you check the newsgroup/list archives (or maybe even Google) you will
also find references to "ping" implemented in Python.

-Peter
 
C

Christoph Becker-Freyseng

Alberto said:
Hello:

Is it possible to make "ping" from Python and get statistics like using
command prompt from Windows?
How Can I capture them into variables?
Thanks

I once searched for ping-modules (which wasn't too easy) and found those:

http://www.python.org/~jeremy/python.html
ftp://ftp.visi.com/users/mdc/ping.py


Hey and I just checked if it is easier to them now :-() and I found one
more:

http://pynms.sourceforge.net/
has a ping-module/class
http://pynms.sourceforge.net/ping.html
and probably is cool if you want to do this network-stuff.

Finally I think the impressing Twisted-Framework had a ping functionality.


Christoph Becker-Freyseng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,787
Messages
2,569,627
Members
45,328
Latest member
66Teonna9

Latest Threads

Top