Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55850
| Date | 2011-02-02 11:44 +0000 |
|---|---|
| From | Tom Boland <tom@t0mb.net> |
| Subject | Re: Perl Hacker, Python Initiate |
| References | <mailman.1576.1296621817.6505.python-list@python.org> <871v3qpwdu.fsf@dpt-info.u-strasbg.fr> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1583.1296648130.6505.python-list@python.org> (permalink) |
if you want to do dns lookups on a large number of hosts, then try looking at gnu adns, or if you don't mind each request blocking until it's complete, then see Alain's response below. I have written some scripts myself which do massively parallel dns lookups quickly using twisted. If this is an excercise in just trying to do a straight port of your program, and you're not interested in doing it in a nicer fashion, then I would see the simple response from Carl Banks, however, you should really have posted the python code you're trying instead! Cheers. Tom. On 02/02/11 10:24, Alain Ketterlin wrote: > Gary Chambers<gwchamb@gwcmail.com> writes: > > >> Given the following Perl script: >> > [41 lines of Perl removed] > > Sorry, I'm lucky enough to be able to completely ignore Perl. > > >> Will someone please provide some insight on how to accomplish that task in >> Python? >> > > From what I understood in the comments of your script, here is a possible > python scriptlet: > > import sys > import socket > canon,aliases,ipaddrs = socket.gethostbyname_ex(sys.argv[1]) > print canon,",".join(aliases),",".join(ipaddrs) > > See also getaddrinfo(). Note that a canonical name may have several ip > addresses (try with www.google.com if you doubt). > > (BTW, this is a direct interface to gethostbyname(), and there is no > real need to use a tool and parse its output.) > > >> I am unable to continually (i.e. it stops after displaying a single >> line) loop through the output while testing for the matches on the two >> regular expressions. Thank you. >> > It is hard to guess what you've tried. See the subprocess package > documentation. > > -- Alain. >
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Perl Hacker, Python Initiate Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-02-02 11:24 +0100 Re: Perl Hacker, Python Initiate Tom Boland <tom@t0mb.net> - 2011-02-02 11:44 +0000
csiph-web