Path: csiph.com!eeepc.pasdenom.info!news.pasdenom.info!news.dougwise.org!aioe.org!feeder.news-service.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.134.4.91.MISMATCH!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sys': 0.04; 'subject:Python': 0.05; 'python?': 0.05; 'socket': 0.05; 'script,': 0.07; 'python': 0.08; 'expressions.': 0.09; 'subprocess': 0.09; 'scripts': 0.09; 'output': 0.10; 'loop': 0.13; 'wrote:': 0.14; 'ignore': 0.15; 'alain': 0.16; 'lookups': 0.16; 'perl.': 0.16; 'tom.': 0.16; 'cc:no real name:2**0': 0.17; '(i.e.': 0.17; 'writes:': 0.17; 'interface': 0.20; 'written': 0.20; 'cc:2**0': 0.21; 'guess': 0.21; 'trying': 0.22; 'header:In- Reply-To:1': 0.23; 'blocking': 0.24; 'cc:addr:python-list': 0.24; 'perl': 0.24; 'code': 0.25; 'posted': 0.26; 'unable': 0.28; "i'm": 0.28; 'gnu': 0.28; 'parallel': 0.28; 'testing': 0.28; 'carl': 0.30; 'stops': 0.30; 'program,': 0.30; 'cc:addr:python.org': 0.30; 'import': 0.31; 'lines': 0.31; 'thank': 0.31; 'however,': 0.32; 'enough': 0.33; 'matches': 0.34; 'parse': 0.34; 'someone': 0.34; 'there': 0.34; 'header:User-Agent:1': 0.34; 'print': 0.35; 'several': 0.35; 'using': 0.35; 'understood': 0.36; 'tool': 0.36; 'regular': 0.37; 'two': 0.38; 'response': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'able': 0.39; 'some': 0.39; 'quickly': 0.39; 'skip:s 30': 0.40; "it's": 0.40; 'comments': 0.40; "you've": 0.61; 'your': 0.61; 'name': 0.61; 'simple': 0.63; 'below.': 0.63; 'here': 0.64; 'lucky': 0.67; 'fashion,': 0.84; 'received:10.44': 0.84; 'subject:Hacker': 0.84; 'banks,': 0.95 Date: Wed, 02 Feb 2011 11:44:30 +0000 From: Tom Boland User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.15) Gecko/20101027 Fedora/3.0.10-1.fc12 Lightning/1.0b1 Thunderbird/3.0.10 MIME-Version: 1.0 To: Alain Ketterlin Subject: Re: Perl Hacker, Python Initiate References: <871v3qpwdu.fsf@dpt-info.u-strasbg.fr> In-Reply-To: <871v3qpwdu.fsf@dpt-info.u-strasbg.fr> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 52 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1296648134 news.xs4all.nl 65870 [::ffff:82.94.164.166]:52010 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:55850 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 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. >