views:

86

answers:

3

In Python, is there a way to ping a server through ICMP and return TRUE if the server responds, or FALSE if there is no response?

+1  A: 

You can look at this recipe:

The MYYN
This requires running Python as root.
Waterfox
+2  A: 

Another pure Python ping implementation that I've used:

http://www.g-loaded.eu/2009/10/30/python-ping/

FogleBird
+1  A: 
import subprocess
ping_response = subprocess.Popen(["/bin/ping", "-c1", "-w100", "192.168.0.1"], stdout=subprocess.PIPE).stdout.read()
mluebke
The only problem with this is that it wouldn't work on Windows.
Waterfox