ping

brandon.mcginty at gmail.com brandon.mcginty at gmail.com
Fri Apr 14 20:37:11 EDT 2006


Try this:
<code>
import os
pinginfo=os.popen("ping www.google.com")
#opens file object with output of the ping to google
print pinginfo.read(-1)
#reads the ping information from the abuv file object
pinginfo.close()
#closes the pinginfo object, as you would do for a standard file object
</code>
Note that pinginfo is actually a file object, and as such, you must treat it
as you would any file you are reading to, readlines, read, etc.
HTH,
Brandon McGinty
 
 
 
 



----------
Feel free to contact me for technical support, or just to chat; I always
have time to talk and help, and an open ear.
Email:Brandon.mcginty at gmail.com
Skype:brandon.mcginty
Msn:brandon_mcginty at hotmail.com
Aim:brandonmcginty (Not currently available.)
Cell:4802025790 (Weekends and nights only, please.)
"Kindness is a language that the deaf can hear and the blind can see."
Mark Twain


-----Original Message-----
From: python-list-bounces+brandon.mcginty=gmail.com at python.org
[mailto:python-list-bounces+brandon.mcginty=gmail.com at python.org] On Behalf
Of david brochu jr
Sent: Friday, April 14, 2006 5:04 PM
To: python-list at python.org
Subject: re: ping


Thanks,
 
Unfortunately substituting os.system with os.popen results in the output
being:

<open file 'ping HYPERLINK "http://www.google.com/" \nwww.google.com
', mode 'r' at 0x009C4650>
<open file 'ping HYPERLINK "http://www.boston.com/" \nwww.boston.com
', mode 'r' at 0x009C4650> 
<open file 'ping HYPERLINK "http://www.espn.com/" \nwww.espn.com
', mode 'r' at 0x009C4650> 
<open file 'ping HYPERLINK "http://www.redsox.com/" \nwww.redsox.com
', mode 'r' at 0x009C4650>
 
instead of giving me the ping stats "pinging etc etc, packets sent 4
recienved 4 etc)
 
Any idea around this?
 



--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.1/312 - Release Date: 4/14/2006





-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.4.1/312 - Release Date: 4/14/2006
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060414/20977853/attachment.html>


More information about the Python-list mailing list