Ping

Remco Gerlich scarblac at pino.selwerd.nl
Wed Nov 15 17:22:56 EST 2000


Krister Bruhwel <bruhwel at localhost.localdomain> wrote in comp.lang.python:
> thanks for the ping.py script.  It seems that it can only be run as
> root, is that so?  I thought about it and I don't thing the root
> will cause security problems, but I will have a hard time accessing
> it from the cgi do to the user being "nobody".  

'ping' is something that only root can do (it uses raw IP packets). 
Fortunately, the normal ping command runs suid root so it will run as
root for anyone.

Therefore, you will have to run the ping command and capture its
output. Try something like

import os
pingoutput = os.popen('ping -c3 www.pythonlabs.com').read()
print pingoutput

You can parse pingoutput in several ways, depends on what you need to
do with the information, and what sort of ping you have.

-- 
Remco Gerlich



More information about the Python-list mailing list