Re: [Tutor] Socket Module

2015-07-30 Thread Nym City via Tutor
Writing to share an update on my previous request. So, after reviewing my code over, it seems like my last print statement "print(ResolvedAddresses)" was not properly indented inside the for loop - and for that reason the output was coming our as empty. After I aligned that with the rest of the l

Re: [Tutor] Socket Module

2015-07-28 Thread Nym City via Tutor
Hi Martin, Thank you for taking the time to write such a detailed response. Very much appreciate it. I tried the code again with modifications that you suggested and even though none of the public addresses resolved; I did get little more details. I am still working on finding a solution for th

Re: [Tutor] Socket Module

2015-07-26 Thread Martin A. Brown
Hello Nym, Here is the updated code: https://bpaste.net/show/358583e1a0bd It's short. I have included inline here: import socket ListOfIPAddresses = [] with open('top500ips.csv', 'r') as f: for line in f: line = line.strip() ListOfIPAddresses.append(line)

Re: [Tutor] Socket Module

2015-07-25 Thread Nym City via Tutor
Thank you all for your responses. I have taken your feedback and made changes to my code. -Danny, per your suggestion, I have renamed some of my variables to make their purpose little more clearer. - Alan,  I have created a new host list (ResolvedAddresses) which is storing the output from socke

Re: [Tutor] Socket Module

2015-07-20 Thread Alan Gauld
On 20/07/15 00:55, Nym City via Tutor wrote: Thank you for your response. I gave it another try: As suggested, first I ran the concept just in the terminal, and it worked fine: names =['173.252.120.6', '98.139.183.24'] import socket for name in names: socket.gethostbyaddr(name) print(

Re: [Tutor] Socket Module

2015-07-19 Thread Danny Yoo
> for name in domains: > socket.gethostbyaddr(name) > print(name) > > output: > 173.252.120.6 > 98.139.183.24 > > What am I missing? Thank in advance. > You have confused yourself a little because the variable names you've chosen are slightly misleading. Specifically, "name" is really an

Re: [Tutor] Socket Module

2015-07-19 Thread Nym City via Tutor
Thank you for your response. I gave it another try: As suggested, first I ran the concept just in the terminal, and it worked fine: >>> names =['173.252.120.6', '98.139.183.24'] >>> import socket >>> for name in names:     socket.gethostbyaddr(name)     print(name)   output:  ('edge-star-shv-12-f

Re: [Tutor] Socket Module

2015-07-18 Thread Danny Yoo
On Jul 18, 2015 3:50 PM, "Nym City via Tutor" wrote: > > Thank you all for your responses. I have a follow up question: > > So if gethostbyname_ex() takes only a single hostname string, how can I use it to go through a list of hostnames and get their IP resolution as an output? > Look into loops.

Re: [Tutor] Socket Module

2015-07-18 Thread Nym City via Tutor
Thank you all for your responses. I have a follow up question: So if gethostbyname_ex() takes only a single hostname string, how can I use it to go through a list of hostnames and get their IP resolution as an output? This would mean,socket.gethostbyaddr() would also not work for my second pro

Re: [Tutor] Socket Module

2015-07-13 Thread Alan Gauld
On 12/07/15 23:36, Nym City via Tutor wrote: import csv import socket domains = open('top500domains.csv', 'r') for domain in domains: domain = socket.gethostbyname(str(domains)) You are passing your file object to gethostbyname() print(domains + "\n") For the code above, I receive

Re: [Tutor] Socket Module

2015-07-12 Thread Danny Yoo
One other thing to note: if you're working with a comma-separated value file (CSV), then you may want to use the 'csv' module to parse it. https://docs.python.org/3.5/library/csv.html This should allow you to walk through the file as if it were a sequence of records. In contrast, if you're d

Re: [Tutor] Socket Module

2015-07-12 Thread Cameron Simpson
On 12Jul2015 22:36, Nym City wrote: Hello, I am working on a 2 individual programs. In the first program, I am taking in a list of domains in .csv format and want to get the associated IPs. In the second program, I want to import in a list of IP .csv and than get the associated domains out. Ev

[Tutor] Socket Module

2015-07-12 Thread Nym City via Tutor
Hello, I am working on a 2 individual programs. In the first program, I am taking in a list of domains in .csv format and want to get the associated IPs. In the second program, I want to import in a list of IP .csv and than get the associated domains out. Eventually I want to get both of the abo