using text file to get ip address from hostname

2012-09-12 Thread dkatorza
hello ,

i'm new to Python and i searched the web and could not find an answer for my 
issue.

i need to get an ip address from list of hostnames which are in a textfile.

this is what i have so far 
--
#!/usr/bin/env python
#Get the IP Address

import socket
hostname = 'need it to read from a text file'
addr = socket.gethostbyname(hostname)
print 'The address of ', hostname, 'is', addr 

---

any idea ? 
sorry for my english

thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: using text file to get ip address from hostname

2012-09-12 Thread dkatorza
בתאריך יום רביעי, 12 בספטמבר 2012 17:24:50 UTC+3, מאת [email protected]:
> hello ,
> 
> 
> 
> i'm new to Python and i searched the web and could not find an answer for my 
> issue.
> 
> 
> 
> i need to get an ip address from list of hostnames which are in a textfile.
> 
> 
> 
> this is what i have so far 
> 
> --
> 
> #!/usr/bin/env python
> 
> #Get the IP Address
> 
> 
> 
> import socket
> 
> hostname = 'need it to read from a text file'
> 
> addr = socket.gethostbyname(hostname)
> 
> print 'The address of ', hostname, 'is', addr 
> 
> 
> 
> ---
> 
> 
> 
> any idea ? 
> 
> sorry for my english
> 
> 
> 
> thanks.

thank you ChrisA
it's not really homework, i found a lab exercise on the web and i;m trying to 
study with it. maybe not the most efficient way.

i have a file with hostnames ordered line by line.

i will check the sources and will get back with outcome.

once again , Thanks,
-- 
http://mail.python.org/mailman/listinfo/python-list