-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping_test.py
More file actions
84 lines (66 loc) · 2.18 KB
/
Copy pathping_test.py
File metadata and controls
84 lines (66 loc) · 2.18 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/python3.9
import os
import time
import subprocess
# made by Eva Witten
def print_options():
print('''
1. Display the default gateway
2. Test local connectivity
3. Test remote connectivity
4. Test DNS resolution
5. Exit/quit the script''')
def default_gateway():
command = "route -n | grep 'UG[ \t]' | awk '{print $2}'"
try:
result = subprocess.run(command, shell=True, capture_output=True, text=True)
return result.stdout
except subprocess.CalledProcessError as e:
return "sybau default mf"
def ping_local():
command = ["ping", "-c", "4", "127.0.0.1"]
try:
result = subprocess.run(command, capture_output=True, text=True, check=True)
return result.stdout
except subprocess.CalledProcessError as e:
return "sybau local mf"
def DNS_resolution():
command = ['ping', '-c', '2', "www.google.com"]
try:
result = subprocess.run(command, capture_output=True, text=True, check=True)
return result.stdout
except subprocess.CalledProcessError as e:
return "sybau default mf"
def ping_command(destination):
command = ['ping', '-c', '2', destination]
try:
result = subprocess.run(command, capture_output=True, text=True, check=True)
return result.stdout
except subprocess.CalledProcessError as e:
return "sybau default mf"
def main():
false = True
while false:
print_options()
choice = input('Enter number of choice: ')
if choice == '1':
os.system('clear')
print("Your gateway :" + default_gateway())
elif choice == '2':
os.system('clear')
print(ping_local())
elif choice == '3':
os.system('clear')
print(ping_command("129.21.3.17"))
elif choice == '4':
os.system('clear')
print(DNS_resolution())
elif choice == '5':
os.system('clear')
print("Goodbye!")
true = False
false = true
else:
print("womp womp do it right\n\n")
if __name__ == "__main__":
main()