gethostbyaddr()

Edward Manning ejmmanning at gmail.com
Mon Jul 28 17:33:23 EDT 2014


I wrote this code, but it seem to work fine if I only have one ip in the file. When I have more than one IP in the file 
I get a error. Does anyone have an idea why.    


import socket
 
 
def main():
 
    # get file names
    infileName = input ("What file our the IP adderss in?  ")
    outfileName = input("What file should the results go in?")
 
    # open files
    infile = open(infileName, "r")
    outfile = open(outfileName, "w")
 
 
    #Proccess each line of the input file
 
    for line in infile:
        ipAddress = line.strip()
        resluts = socket.gethostbyaddr(ipAddress)
        print(resluts[0],resluts[2], end="")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140728/5c86f135/attachment.html>


More information about the Python-list mailing list