import platform
import subprocess
def main():
choice = 0
while choice != 2:
choice = get_menu_choice()
if choice == 1:
run_ip_config()
if choice == 2:
print("Thanks for checking the IP address configuration")
def get_menu_choice():
print("---------Interface Configuration Display---------")
print("1. Check the ip addresss configuration")
print("2. Quit the program")
choice = int(input("Enter a choice from the menu above"))
choice = validate_choice(choice)
return choice
while choice != 1 and choice !=2:
print("Invalid choice. Choose from the following:")
print("1. Check the ip address configuration")
print("2. Quit the program")
choice = int(input("Enter a choice from the menu above:"))
def validate_choice(choice):
while choice !=1 and choice !=2:
print(“Invalid choice. Choose from the following:”)
print(“1. Check the ip address configuration.”)
print(“2. Quit the program.”)
choice = int(input(“Enter a choice from the menu above:”))
return choice
def run_ip_config():
oper = platform.system
print(oper)
if oper == “Windows”:
command = “ipconfig”
argument = “/all”
else:
command = “ifconfig”
argument = “-a”
p1 = subprocess.Popen([command, argument], stdout=subprocess.PIPE, text=True)
p2 = subprocess.run([command, argument], stdout=subprocess.PIPE)
output = p1.communicate()[0]
print(output)
print(p2.stdout.decode())
main()
<function system at 0x0000018AC2A0E680>
Traceback (most recent call last):
File “C:\Users\karie\Desktop\ITP270\final_project_review.py”, line 68, in
main()
File “C:\Users\karie\Desktop\ITP270\final_project_review.py”, line 18, in main
run_ip_config()
File “C:\Users\karie\Desktop\ITP270\final_project_review.py”, line 60, in run_ip_config
p1 = subprocess.Popen([command, argument], stdout=subprocess.PIPE, text=True)
File “C:\Users\karie\AppData\Local\Programs\Python\Python310\lib\subprocess.py”, line 966, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File “C:\Users\karie\AppData\Local\Programs\Python\Python310\lib\subprocess.py”, line 1435, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified