I am working with this python script. I want it to dump all hosts which are alive into a text file and discard all hosts which don't respond to the ping. Currently I have this part.
#!/usr/bin/python2
import subprocess
import sys
ip = "10.11.1."
for sub in range (0,255):
sweep = subprocess.Popen("ping -c 1 "+ ip+str(sub), shell=True,
stderr=subprocess.PIPE)
out = sweep.stderr.read(1)
sys.stdout.write(out)
How would I add the part dumping relevant information into a .txt file?