Edward Manning ejmmanning at
Mon Jul 28 23:33:23 CEST 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: <>

More information about the Python-list mailing list