Want to write a script to do the batch conversion from domain name to IP.

Hongyi Zhao hongyi.zhao at gmail.com
Fri Jan 30 09:53:33 EST 2009


On Fri, 30 Jan 2009 22:48:00 +0800, Hongyi Zhao
<hongyi.zhao at gmail.com> wrote:

>On Fri, 30 Jan 2009 05:41:29 -0800 (PST), Jeff McNeil
><jeff at jmcneil.net> wrote:
>[snipped]
>>Why not just use socket.gethostbyname?
>>
>>Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
>>[GCC 4.3.2] on linux2
>>Type "help", "copyright", "credits" or "license" for more information.
>>>>> import socket
>>>>> socket.gethostbyname('ip-72-55-191-6.static.privatedns.com')
>>'72.55.191.6'
>>>>>
>
>See the following errors I in my case:
>
>$ python
>'import site' failed; use -v for traceback
>Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
>[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
>Type "help", "copyright", "credits" or "license" for more information.
>>>> import socket
>Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>ImportError: No module named socket
>>>> socket.gethostbyname('ip-72-55-191-6.static.privatedns.com')
>Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>NameError: name 'socket' is not defined

Sorry for my carelessness.  It's obviously due to the lack of the
socket module in my case.

Another issue is: how can I perform all of these steps in a python
script?

-- 
.: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.



More information about the Python-list mailing list