import os import time #Menu (choose) os.system("cls") print() print("====================") print("LAN SCANNING BY PING") print("====================") print() print("1) Whole LAN scanning") print("2) One host scanning") print("3) Settings") print("0) Exit") choose = int(input("Enter [1], [2], [3] or [0]: ")) #Whole LAN scanning if choose==1: print() inp = open("C:/Users/Adam/Desktop/ping/new.txt", "r") tnp = open("C:/Users/Adam/Desktop/ping/new2.txt", "r") break_line = "-" print(break_line * 56) activehosts = [] unactivehosts = [] for one_line in inp.readlines(): one_line = one_line.rstrip() response = os.system("ping " + one_line + " -n 1") if response==0: activehosts.append(one_line) print("Host {} is active".format(one_line)) elif response==1: unactivehosts.append(one_line) print("Host {} is unactive or unreachable".format(one_line)) print(break_line * 56) time.sleep(1) for one_name in tnp.readlines(): one_name = one_name.rstrip() print() print("Active hosts:") for x in activehosts: print(x) print() print("Unactive or unreachable hosts: ") for x in unactivehosts: print(x) inp.close #One host scanning elif choose==2: print() server_ip = input("Enter server's ip: ") response = os.system("ping " + server_ip + " -n 1") print() if response==0: print("Host {} is active ".format(server_ip)) else: print("Host {} is unactive or unreachable".format(server_ip)) #Settings elif choose==3: print() print("1) Show ip board file") print("2) Edit ip board file") print("0) Exit") a = int(input("Enter [1], [2] or [0]: ")) if a==1: print() filename = 'C:/Users/Adam/Desktop/ping/new.txt' inp = open("C:/Users/Adam/Desktop/ping/new.txt", "r") lc = 0 for one_line in inp.readlines() : lc += 1 one_line = one_line.rstrip() print("{}) {}".format(lc, one_line)) time.sleep(0.5) inp.close elif a==2: filename = 'C:/Users/Adam/Desktop/ping/new.txt' os.startfile(filename) elif a==3: exit() #Exit option elif choose==0: exit() #Afrer complete above code print() restart = int(input("Enter [1] to restart the program or [0] to exit it: ")) if restart == 1: os.system("cls") os.system("python C:/Users/Adam/Desktop/ping/file.py") else: exit()