Question: improve script. This is supposed to ping each host twice in a subnet and only print those that are active. import os network =
improve script. This is supposed to ping each host twice in a subnet and only print those that are active.
import os
network = input ("Enter first 3 numbers of IP network, e.g. 1.2.3: ")
print(network)
hosts_scanned = 0
for host in range (1, 255):
response = os.popen("ping -n 2 " + network + "." + str(host))
if "TTL" in response.readlines():
print("Host " + network + "." + str(host) + " reachable. ")
hosts_scanned += 1
print("Total hosts scanned: ", hosts_scanned)
Step by Step Solution
There are 3 Steps involved in it
Answer To improve the script several changes can be made to make it more efficient and robust Use th... View full answer
Get step-by-step solutions from verified subject matter experts
