Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.044 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'socket': 0.07; 'subject:()': 0.09; 'def': 0.12; 'wrote': 0.14; '"r")': 0.16; '"w")': 0.16; 'main():': 0.16; 'code,': 0.22; 'input': 0.22; 'import': 0.22; 'why.': 0.24; 'fine': 0.24; 'file.': 0.24; 'idea': 0.28; 'anyone': 0.31; 'file': 0.32; 'open': 0.33; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'charset:us- ascii': 0.36; 'should': 0.36; 'error.': 0.37; 'message- id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'header:Message-Id:1': 0.63; 'our': 0.64; 'more': 0.64; 'results': 0.69; 'subject:skip:g 10': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:message-id:date:to:mime-version; bh=U2Q2eMJrpUP78Z6FcDuaXmtG0sq0IRzFAuKBEER1Qm0=; b=jOhXEOr5wQGUdwoJ7n+1+PXjZd7vhqGoStOSCFlf2yUmSlXeXC9WM2nA0qIVu+tZS1 tdH4Wf7tft9XMCz9iX3oxN22FA41WI88NVwlA396gXnbsKq2RXrjAQWxXZOlMIAv61KN K1l8wtSgLbV7hVBrVU7Spyy8V4msykAyJnByPiAnG4W6G50oz1/eHUc/w9S4homVGZiy fB0ZLfyx8yf2Ts9eUXv9HXhjJaJUeUcBMWSPiqsDHQCMQux6o3tC7E1oqLyK6sdpSuYE vHeaokDp7LNnPzanUhBa+N+AjQLZqecbCU5aw44C2xM2UJcrp8NnvQqGHGzGQdSBThP9 Yh8w== X-Received: by 10.224.89.10 with SMTP id c10mr65389884qam.51.1406583206127; Mon, 28 Jul 2014 14:33:26 -0700 (PDT) From: Edward Manning Content-Type: multipart/alternative; boundary="Apple-Mail=_00A54C0E-954D-4652-A5B6-5E534D7852F7" Subject: gethostbyaddr() Date: Mon, 28 Jul 2014 17:33:23 -0400 To: python-list@python.org Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1971.5\)) X-Mailer: Apple Mail (2.1971.5) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 102 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1406583208 news.xs4all.nl 2941 [2001:888:2000:d::a6]:36874 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75327 --Apple-Mail=_00A54C0E-954D-4652-A5B6-5E534D7852F7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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=20 I get a error. Does anyone have an idea why. =20 import socket =20 =20 def main(): =20 # get file names infileName =3D input ("What file our the IP adderss in? ") outfileName =3D input("What file should the results go in?") =20 # open files infile =3D open(infileName, "r") outfile =3D open(outfileName, "w") =20 =20 #Proccess each line of the input file =20 for line in infile: ipAddress =3D line.strip() resluts =3D socket.gethostbyaddr(ipAddress) print(resluts[0],resluts[2], end=3D"")= --Apple-Mail=_00A54C0E-954D-4652-A5B6-5E534D7852F7 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii

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 =3D input ("What file our the = IP adderss in?  ")

    outfileName =3D input("What = file should the results go in?")

 

    # open files

    infile =3D = open(infileName, "r")

    outfile =3D open(outfileName, = "w")

 

 

    #Proccess each line of the input = file

 

    for line in infile:

        ipAddress =3D = line.strip()

        resluts =3D = socket.gethostbyaddr(ipAddress)

        = print(resluts[0],resluts[2], end=3D"")

= --Apple-Mail=_00A54C0E-954D-4652-A5B6-5E534D7852F7--