Skip to content

Instantly share code, notes, and snippets.

@pqlx
Created June 7, 2018 11:53
Show Gist options
  • Save pqlx/168e9fc938c9e9f387268e0931e05762 to your computer and use it in GitHub Desktop.
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
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