Created
April 24, 2018 01:19
-
-
Save j67678/193942d5e0deb9c4ce8499dd7adb2064 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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