import os
import subprocess
iplist=[]
def pingCheck(ip):
p = subprocess.Popen("ping -n 1 %s"%ip,\
stdin = subprocess.PIPE,\
stdout = subprocess.PIPE,\
stderr = subprocess.PIPE,\
shell = True)
out = p.stdout.read()
print out
if "TTL" in str(out):
print "ping %s is ok"%ip
iplist.append(ip)
else:
print "ping %s is fail"%ip
def main():
for x in range(1,255):
pingCheck("192.168.199."+str(x))
print str(iplist)
if __name__=="__main__":
main()
import subprocess
iplist=[]
def pingCheck(ip):
p = subprocess.Popen("ping -n 1 %s"%ip,\
stdin = subprocess.PIPE,\
stdout = subprocess.PIPE,\
stderr = subprocess.PIPE,\
shell = True)
out = p.stdout.read()
print out
if "TTL" in str(out):
print "ping %s is ok"%ip
iplist.append(ip)
else:
print "ping %s is fail"%ip
def main():
for x in range(1,255):
pingCheck("192.168.199."+str(x))
print str(iplist)
if __name__=="__main__":
main()