Created
June 7, 2018 11:53
-
-
Save pqlx/168e9fc938c9e9f387268e0931e05762 to your computer and use it in GitHub Desktop.
script to quickly filter out domains that either don't exist or are down
This file contains 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 subprocess, sys, os | |
dev_null = open(os.devnull, 'w') | |
up = [] | |
with open(sys.argv[1], 'r') as handle: | |
while True: | |
curr = handle.readline() | |
if curr == "": | |
break | |
curr = curr.strip() | |
c = subprocess.Popen(["ping", curr, '-W', '2', '-c' '1'], stdout=dev_null, stderr=subprocess.STDOUT) | |
c.communicate() | |
if c.returncode == 0: | |
up.append(curr) | |
print(f"found: {curr}") | |
open("out.txt", 'w').write('\n'.join(up)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment