views:

49

answers:

2

I want to make a little tk app that continuous ping an ip and only show the MS, like, "10ms"

how could I do?

A: 

To continuously ping an IP

os.system("ping -t 192.168.1.1")
S.Mark
+1  A: 

If you want to use Windows ping, you'll have to parse the output from the command line.

This is very specific, but should work:

import os
while(1):
    ping = os.popen('ping www.google.com -n 1')
    result = ping.readlines()
    msLine = result[-1].strip()
    print msLine.splot(' = ')[-1]
Mike Cialowicz
thx, work like a charm
Shady
No problem. I suggest you print the result of each line, so you can see exactly what it's doing. Also: please accept the answer. Thanks!
Mike Cialowicz