Skip to content

Instantly share code, notes, and snippets.

@fishy fishy/apple.py
Created Jun 29, 2011

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.