I have a script that reads addresses from a file and looks up its hostname with socket.gethostbyaddr, however the return of this function is messy and doesn't look right.
The line where it writes to the destination file reads:
destfile.write(str(socket.gethostbyaddr(ip)))
The results come out like this when it reads 8.8.8.8:
('google-public-dns-a.google.com', [], ['8.8.8.8])
However, I only need that first output, google-public-dns-a.google.com. I hope to have it write to the file and look like this:
8.8.8.8 resolves to google-public-dns-a.google.com
Anyone know how to split this? Can provide more code if needed.