improve script. This is supposed to ping each host twice in a subnet and only print those
Fantastic news! We've Found the answer you've been seeking!
Question:
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)
Related Book For
Posted Date: