By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,857 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,857 IT Pros & Developers. It's quick & easy.

ping - statistics

P: n/a
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

Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
> Alberto Vera wrote:

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
Jul 18 '05 #2

P: n/a
Alberto Vera wrote:
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

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.