Ping

Matthew Dixon Cowles matt at mondoinfo.com
Fri Mar 1 15:51:46 EST 2002


On Fri, 1 Mar 2002 18:21:13 +0100, Riss Nicolas
<alien275 at libertysurf.fr> wrote:

>Bonjour,

Bonjour!

>on ma dit que je pouvais écrire en francais alors j'écrit en
>francais.

Of course it's reasonable to write in French here. I hope you will
forgive me for replying in English because my French is sufficient for
reading but rarely for writing.

>Je voudrais pouvoir vérifier toutes les 5 min que une machine ping
>une autre machine et si elle ne ping pas qu'elle execute un
>script. Comment faut il faire avec python pour pinger une machine et
>vérifier qu'elle répond??

Jeremy Hylton has Python code to do ping and traceroute at:

http://www.python.org/~jeremy/python.html

and my ping.py is at:

ftp://ftp.visi.com/users/mdc/ping.py

In order to open the raw socket that's necessary to send a ping,
you'll need root authority under Unix and I don't think it's possible
at all under Windows 9X. You might find it simpler or safer to use
os.popen() to run your system's ping and parse its output.

Andrae Muys points out in (wrapped for line length):

http://groups.google.com/groups?
  selm=7934d084.0201081621.177c1c8e%40posting.google.com

that it may also be possible to use an ordinary socket to connect to
an ordinary port on the second machine and interpret any error message
you get. You might have to experiment some to see what result was
"normal" and what results represented errors.

A bientot,
Matt



More information about the Python-list mailing list