Skip to content

Instantly share code, notes, and snippets.

@fishy
Created June 29, 2011 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fishy/1052589 to your computer and use it in GitHub Desktop.
Save fishy/1052589 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import subprocess
import re
wanted = re.compile(re.compile(r'time=\d\d(\.\d*)? ms'))
host_pattern = 'a%d.phobos.apple.com'
cmd_pattern = 'ping -c 4 %s'
result = []
for i in xrange(1,2001) :
host = host_pattern % i
cmd = cmd_pattern % host
sys.stderr.write("pinging %s...\n" % host)
output = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE).communicate()[0]
if (wanted.search(output)) : result.append(output)
for r in result :
print r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment