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 =[‘ping’, ‘-c’, ‘1’, address])
if res == 0:
print (“ping to”, address, “OK”)
elif res == 1:
print (“no response from”, address)
print (“ping to”, address, “failed!”)




Leave a Reply

Your email address will not be published.