using text file to get ip address from hostname

dkatorza at gmail.com dkatorza at gmail.com
Wed Sep 12 10:24:46 EDT 2012


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.



More information about the Python-list mailing list