ping - statistics

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alberto Vera

    ping - statistics

    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

  • Peter Hansen

    #2
    Re: ping - statistics

    > Alberto Vera wrote:[color=blue]
    >
    > Is it possible to make "ping" from Python and get statistics like using command prompt from Windows?
    > How Can I capture them into variables?[/color]

    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

    Comment

    • Christoph Becker-Freyseng

      #3
      Re: ping - statistics

      Alberto Vera wrote:[color=blue]
      > 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[/color]

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

      The official home of the Python Programming Language

      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:

      Download pyNMS for free. This project has been renamed "pycopia", and extended. This is no longer maintained.

      has a ping-module/class

      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



      Comment

      Working...