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

1 Expert Approved Answer
Step: 1 Unlock

Answer To improve the script several changes can be made to make it more efficient and robust Use th... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Operating System Questions!