Mailing List Archive

catching results of ping on NT
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
catching results of ping on NT [ In reply to ]
[posted and mailed]

Benjamin Derstine <bend@realeducation.com> wrote in
<7ha62g$8fd$1@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@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
catching results of ping on NT [ In reply to ]
On Tue, 11 May 1999 15:09:41 -0600, "Benjamin Derstine" <bend@realeducation.com>
wrote:
>I'm trying to write a script that saves the results of the ping command on
>NT.

Benjamin,

there's a related FAQ entry for this:

http://www.python.org/doc/FAQ.html#1.13

You'll need the Pythonwin extensions for the win32pipe module.

Stefan
catching results of ping on NT [ In reply to ]
Sorry, typo. Should have been

http://www.python.org/doc/FAQ.html#7.13

Stefan
catching results of ping on NT [ In reply to ]
I have a wrapper for os.system() that captures the results
(stdout and stderr). It's a little bit clunky, because it uses
temporary files. But I originally had problems with popen()
hanging on me, and this route seemed more robust.

syscmd.py at http://starship.python.net/~jjkunce/=20

--Jeff

>>> "Benjamin Derstine" <bend@realeducation.com> 05/11/99 04:09PM >>>
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