catching results of ping on NT

Duncan Booth duncan at rcp.co.uk
Wed May 12 04:03:59 EDT 1999


[posted and mailed]

Benjamin Derstine <bend at realeducation.com> wrote in 
<7ha62g$8fd$1 at birch.prod.itd.earthlink.net>:

>I'm trying to write a script that saves the results of the ping command on
>NT.  I can make the ping command happen with os.system('ping...') .
>However, I can't figure out how to get the results of this command into a
>Python data structure.  I've studied the os and sys modules but they don't
>seem to have anything that can do this.
>Thanks,
>
>Ben
>
Try using popen:
 result = os.popen('ping -n 3 localhost').readlines()


-- 
Duncan Booth                                    duncan at dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan




More information about the Python-list mailing list