Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- ips =[]
- hops =[]
- time=[]
- output = '''
- Tracing route to www.google.com [216.58.210.228]
- over a maximum of 30 hops:
- 1 7 ms 3 ms 3 ms 192.168.1.1
- 2 * 75 ms * 10.13.255.10
- 3 73 ms 26 ms 25 ms 62.169.249.253
- 4 80 ms 27 ms 26 ms 62.169.249.174
- 5 * * * Request timed out.
- 6 27 ms 25 ms 28 ms 195.22.193.45
- 7 43 ms 50 ms 44 ms 89.221.39.4
- 8 46 ms 45 ms 46 ms 72.14.216.248
- 9 49 ms 48 ms 45 ms 72.14.238.133
- 10 61 ms 61 ms 60 ms 209.85.253.114
- 11 81 ms 78 ms 86 ms 72.14.234.11
- 12 73 ms 106 ms 89 ms 72.14.232.77
- 13 81 ms 81 ms 79 ms 209.85.253.11
- 14 77 ms 78 ms 78 ms 66.249.94.47
- 15 78 ms 79 ms 80 ms 216.58.210.228
- Trace complete.
- '''
- for line in output.splitlines():
- if re.match('\s+\d+', line):
- cols = line.split()
- print cols
- if line.endswith('Request timed out.'): # I had to replace this with if line.endswith('Request timed out.\r\n'):
- hop, times, ip = cols[0], '* * *', 'Request timed out.'
- else:
- hop, times, ip = cols[0], ' '.join(cols[1:-1]), cols[-1]
- ips.append(ip)
- hops.append(hop)
- time.append(times)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement