Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75327
| From | Edward Manning <ejmmanning@gmail.com> |
|---|---|
| Subject | gethostbyaddr() |
| Date | 2014-07-28 17:33 -0400 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12399.1406583208.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
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="")
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
gethostbyaddr() Edward Manning <ejmmanning@gmail.com> - 2014-07-28 17:33 -0400
csiph-web