Skip to content

Instantly share code, notes, and snippets.

@j67678
Created April 24, 2018 01:19
Show Gist options
  • Save j67678/193942d5e0deb9c4ce8499dd7adb2064 to your computer and use it in GitHub Desktop.
Save j67678/193942d5e0deb9c4ce8499dd7adb2064 to your computer and use it in GitHub Desktop.
import os
import subprocess
domains = open('domains.txt').read().splitlines()
domains_ok = open('domains_ok.txt', 'w')
domains_fail = open('domains_fail.txt', 'w')
for domain in domains:
p = subprocess.Popen(['ping', domain], stdout=subprocess.PIPE)
streamdata = p.communicate()[0]
ret = p.returncode
#ret = os.system('ping {}'.format(domain))
if ret == 0:
domains_ok.write(domain + '\n')
print domain + ': ok'
else:
domains_fail.write(domain + '\n')
print domain + ': fail'
domains_ok.close()
domains_fail.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment