I got 3 scripts.
1st script scans subnets and prints out Active and not Active IPs.
2d script opens file with Active IPs and finds corresponding Active Hosts names.
3d script opens file with the Active Hosts names and pulls out some stuff from it.
When I ran each script separately, I have no errors or problems but when put all three of them in to one script it hangs on the second script with no errors and never starts third part of the script.
############################################################################################
[sub]import socket
import sys
pfile = open('C:/Python_TEST/IP_Scan/Lists/IP_Active1.txt')
h_active = open("C:/Python_TEST/IP_Scan/Lists/IP_Host_Active.txt","w")
sys.stdout = h_active
while True:
IP = pfile.readline()
try:
host = socket.gethostbyaddr(IP.rstrip())
#(IP.rstrip())
#host = socket.gethostbyaddr(IP.rstrip())
print (IP,file=h_active)
print(IP,host)
except Exception as e:
print(IP,"NULL")
pfile.close()
h_active.close()[/sub]
1st script scans subnets and prints out Active and not Active IPs.
2d script opens file with Active IPs and finds corresponding Active Hosts names.
3d script opens file with the Active Hosts names and pulls out some stuff from it.
When I ran each script separately, I have no errors or problems but when put all three of them in to one script it hangs on the second script with no errors and never starts third part of the script.
############################################################################################
[sub]import socket
import sys
pfile = open('C:/Python_TEST/IP_Scan/Lists/IP_Active1.txt')
h_active = open("C:/Python_TEST/IP_Scan/Lists/IP_Host_Active.txt","w")
sys.stdout = h_active
while True:
IP = pfile.readline()
try:
host = socket.gethostbyaddr(IP.rstrip())
#(IP.rstrip())
#host = socket.gethostbyaddr(IP.rstrip())
print (IP,file=h_active)
print(IP,host)
except Exception as e:
print(IP,"NULL")
pfile.close()
h_active.close()[/sub]