ping sweep in python

This simple script will perform ping sweep, all you need to do is add header in file and make it executable.

 

import subprocess

for ping in range(1,256):
address = “127.0.0.” + str(ping)
res = subprocess.call([‘ping’, ‘-c’, ‘1’, address])
if res == 0:
print (“ping to”, address, “OK”)
elif res == 1:
print (“no response from”, address)
else:
print (“ping to”, address, “failed!”)

 

 

0 Comments

Leave a Reply

Your email address will not be published.