An ICMP ping is the most common type of network scanning you have ever encountered. It is very easy to open a command-line prompt or terminal and type
ping www.google.com. How difficult is that from inside a Python program? This recipe shows you an example of a Python ping.
You need the superuser or administrator privilege to run this recipe on your machine.
You can lazily write a Python script that calls the system ping command-line tool, as follows:
import subprocess import shlex command_line = "ping -c 1 www.google.com" args = shlex.split(command_line) try: subprocess.check_call(args,stdout=subprocess.PIPE,\ stderr=subprocess.PIPE) print "Google web server is up!" except subprocess.CalledProcessError: ...