Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import re
- proc = subprocess.Popen('tracert -d www.google.com',stdout=subprocess.PIPE,shell=True)
- while True:
- line = proc.stdout.readline()
- if re.match('\s+\d+', line):
- cols = line.split()
- if line.endswith('Request timed out.'):
- hop, times, ip = cols[0], '* * *', 'Request timed out.'
- else:
- hop, times, ip = cols[0], ' '.join(cols[1:-1]), cols[-1]
- print hop
- print times
- print ip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement