forked from shrish-sharma-codes/The-Python-Archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrace_route.py
More file actions
27 lines (25 loc) · 888 Bytes
/
trace_route.py
File metadata and controls
27 lines (25 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os, time
to_ping = input("To whom you want to Ping? ")
i=0
while True:
i = i + 1
os.system(f'date >> /home/trace_route.txt')
exit_status = os.system(f'ping -c1 {to_ping} >> /home/trace_route.txt')
os.system(f'traceroute {to_ping} >> /home/trace_route.txt')
os.system(f"echo '' >> /home/trace_route.txt")
os.system(f"echo '' >> /home/trace_route.txt")
print('Test Case: #' + str(i))
if exit_status!=0:
print('Connection Lost!')
break
time.sleep(1)
i = 0
while i<6:
i = i + 1
os.system(f'date >> /home/trace_route.txt')
exit_status = os.system(f'ping -c1 {to_ping} >> /home/trace_route.txt')
os.system(f'traceroute {to_ping} >> /home/trace_route.txt')
os.system(f"echo '' >> /home/trace_route.txt")
os.system(f"echo '' >> /home/trace_route.txt")
print('Extra Test Case: #' + str(i))
time.sleep(1)