Background: I have always wanted to try my hand at scripting so here goes!
Problem: When gethostbyaddr gets to an IP with no DNS entry it errors and my script doesn't continue on.
Here is what I have so far:
import socket
file = 'ServerList'
f = open(file, 'r')
lines = f.readlines()
f.close()
for i in lines:
host = i.strip()
if socket.gethostbyaddr(host) return(True):
val1 = socket.gethostbyaddr(host)
print("%s - %s" % (host, val1))
else:
print ("%s - No Entry" % (host))
But it errors probably because the return(True) is not proper syntax.
Can anyone help?
Thanks, J