[24675] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6837 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 5 09:11:42 2004

Date: Thu, 5 Aug 2004 06:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 5 Aug 2004     Volume: 10 Number: 6837

Today's topics:
        Lookuping IP address using four nameservers at the same <artgh@hotmail.com>
    Re: Lookuping IP address using four nameservers at the  <regner@dievision.de>
    Re: Lookuping IP address using four nameservers at the  <nospam@bigpond.com>
    Re: Lookuping IP address using four nameservers at the  <nospam@bigpond.com>
    Re: Lookuping IP address using four nameservers at the  <nobull@mail.com>
    Re: Lookuping IP address using four nameservers at the  <regner@dievision.de>
    Re: name of perl jobs newsgroup? <someone@example.com>
    Re: recursive functions [Silly Joke] <regner@dievision.de>
    Re: recursive functions <wksmith@optonline.net>
    Re: recursive functions (Anno Siegel)
    Re: recursive functions <richard@zync.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 05 Aug 2004 17:42:14 +0800
From: Facco Eloelo <artgh@hotmail.com>
Subject: Lookuping IP address using four nameservers at the same time.
Message-Id: <41180078.265946801@news.individual.net>

I have 4 DNS servers
e.g.
111.111.111.111;
222.222.222.222;
111.222.111.222;
222.111.222.111.
They are fake here for secure reason;-)

When I want to get a domain's IP,I usually type:

"nslookup"-->"server 111.111.111.111"-->"www.aaa.com"
then "server 222.222.222.222"-->"www.aaa.com" 
and then "server 111.222.111.222"-->"www.aaa.com" 
and then "server 222.111.222.111"-->"www.aaa.com" 

But I find it costs lots of my time.

Is there a tool (or just a perl script) which can set four nameservers(or more)
*at the same time* to query?

Thank you in advance.


------------------------------

Date: Thu, 05 Aug 2004 12:17:13 +0200
From: Tom Regner <regner@dievision.de>
Subject: Re: Lookuping IP address using four nameservers at the same time.
Message-Id: <4112091d$0$5987$4d3ebbfe@news1.pop-hannover.net>

Facco Eloelo wrote:

> I have 4 DNS servers
> e.g.
> 111.111.111.111;
> 222.222.222.222;
> 111.222.111.222;
> 222.111.222.111.
> They are fake here for secure reason;-)
> 
> When I want to get a domain's IP,I usually type:
> 
> "nslookup"-->"server 111.111.111.111"-->"www.aaa.com"
> then "server 222.222.222.222"-->"www.aaa.com"
> and then "server 111.222.111.222"-->"www.aaa.com"
> and then "server 222.111.222.111"-->"www.aaa.com"
> 
> But I find it costs lots of my time.
> 
> Is there a tool (or just a perl script) which can set four nameservers(or
> more) *at the same time* to query?
> 
> Thank you in advance.

Short of using Net-DNS (http://search.cpan.org/~crein/Net-DNS-0.47_01/)
if it's just a little helper, why not use something like this:

#!/bin/env perl
use warnings;
use strict;
my @dnss = qw(111.111.111.111 
              222.222.222.222 
              111.222.111.222 
              222.111.222.111);

my $host = $_[0];

foreach (@dnss) {
    my $res = qx/nslookup -type=A $host $_/;
    (print $res and exit(0)) if $res;
}

called as './script.pl searchterm'
(untested)
hth,
Tom
-- 
Dievision GmbH | Kriegerstrasse 44 | 30161 Hannover
Telefon: (0511) 288791-0 | Telefax: (0511) 288791-99
http://www.dievision.de


------------------------------

Date: Thu, 05 Aug 2004 20:17:57 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Lookuping IP address using four nameservers at the same time.
Message-Id: <2nefquFvjjlsU1@uni-berlin.de>

Facco Eloelo wrote:

> I have 4 DNS servers
> e.g.
> 111.111.111.111;
> 222.222.222.222;
> 111.222.111.222;
> 222.111.222.111.
> They are fake here for secure reason;-)
> 
> When I want to get a domain's IP,I usually type:
> 
> "nslookup"-->"server 111.111.111.111"-->"www.aaa.com"
> then "server 222.222.222.222"-->"www.aaa.com"
> and then "server 111.222.111.222"-->"www.aaa.com"
> and then "server 222.111.222.111"-->"www.aaa.com"
> 
> But I find it costs lots of my time.
> 
> Is there a tool (or just a perl script) which can set four nameservers(or
> more) *at the same time* to query?
> 
> Thank you in advance.

I'm trying to do something similar - given a domain, try to do dig, whois &
ping in parallel.

The first attempt was a non-blocking pipe open. But to do it for multiple
files it needs co-routines which are not simple to implement:
http://tinyurl.com/5jwwg

Another approach I'm considering is
1. Start a number of processes in the background, writing to temp files: 
system("command1 arg1 &>/tmp/file1");
system("command2 argt2 &>/tmp/file2");
system("command3 argt3 &>/tmp/file3");

2. Read each of /tmp/file* by polling them in a loop and sleeping for say 1
sec .
3. Parse the files

Either approach is not pretty.

gtoomey


------------------------------

Date: Thu, 05 Aug 2004 20:20:38 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Lookuping IP address using four nameservers at the same time.
Message-Id: <2nefvmFvjjlsU2@uni-berlin.de>

Tom Regner wrote:

> Facco Eloelo wrote:
> 

>> Is there a tool (or just a perl script) which can set four nameservers(or
>> more) *at the same time* to query?
>> 
 ....
> foreach (@dnss) {
>     my $res = qx/nslookup -type=A $host $_/;
>     (print $res and exit(0)) if $res;
> }
> 

The OP wants the results in parallel. This does it sequentially.

gtoomey


------------------------------

Date: Thu, 05 Aug 2004 13:08:58 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Lookuping IP address using four nameservers at the same time.
Message-Id: <cet7p7$die$1@sun3.bham.ac.uk>


Facco Eloelo wrote:
> 
> Is there a tool (or just a perl script) which can set four nameservers(or more)
> *at the same time* to query?

In the Net::DNS examples there is a script that looks up several names 
on one server at once.  It would not be too hard to make it look up one 
address on several servers at once.

http://search.cpan.org/~crein/Net-DNS/demo/mresolv

However I would query why you think that you want to do this.  Are you 
debugging DNS propagation?  In the normal course of events you'd just 
ask you local recursive nameserver and let it do all the work.



------------------------------

Date: Thu, 05 Aug 2004 14:40:23 +0200
From: Tom Regner <regner@dievision.de>
Subject: Re: Lookuping IP address using four nameservers at the same time.
Message-Id: <41122aab$0$5987$4d3ebbfe@news1.pop-hannover.net>

Facco Eloelo wrote:

> I have 4 DNS servers
> e.g.
> 111.111.111.111;
> 222.222.222.222;
> 111.222.111.222;
> 222.111.222.111.
> They are fake here for secure reason;-)
> 
> When I want to get a domain's IP,I usually type:
> 
> "nslookup"-->"server 111.111.111.111"-->"www.aaa.com"
> then "server 222.222.222.222"-->"www.aaa.com"
> and then "server 111.222.111.222"-->"www.aaa.com"
> and then "server 222.111.222.111"-->"www.aaa.com"
> 
> But I find it costs lots of my time.
> 
> Is there a tool (or just a perl script) which can set four nameservers(or
> more) *at the same time* to query?
> 
> Thank you in advance.

working version of my previously posted code, still just a draft, but tested
(with real servers) and working:

#!/bin/env perl
use warnings;
use strict;
use IPC::ShareLite;
use Storable qw(thaw freeze);
use File::Temp qw(tempfile);
use Fcntl ':flock';
use POSIX ":sys_wait_h";

my $store = new IPC::ShareLite( -key => "__dnssearch__",
                                      -create  => 'yes',
                                      -destroy => 'no' ) or die "Store: " .
$!;

my $results = {};

$store->store(freeze($results));

my @dnss = qw(111.111.111.111 
              222.222.222.222 
              111.222.111.222 
              222.111.222.111);

my $host = $ARGV[0];
my @children = ();
my $lock = tempfile();

foreach (@dnss) {
    my $dns = $_;
    my $parent = fork();
    if (!$parent) {
        my $command = "nslookup -type=A $host $dns 2>/dev/null";
        my $res = qx/$command/;
        my $store = new IPC::ShareLite( -key => "__dnssearch__",
                                      -create  => 'yes',
                                      -destroy => 'no' ) or warn ("Child $_:
". $!);
        flock($lock, LOCK_EX);
        my $results = thaw($store->fetch());
        $results->{$dns} = $res;
        $store->store(freeze($results));
        flock($lock, LOCK_UN);
       exit(0);
    } else {
        die "couldn't fork!" unless $parent;
        push(@children, $parent);
    }
}
for (@children) {waitpid($_, 0);}

$results = thaw($store->fetch());
use Data::Dumper;
print Data::Dumper->Dump([$results,],["result"]);
#
# do something with results
# 

-- 
Dievision GmbH | Kriegerstrasse 44 | 30161 Hannover
Telefon: (0511) 288791-0 | Telefax: (0511) 288791-99
http://www.dievision.de


------------------------------

Date: Thu, 05 Aug 2004 12:02:47 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: name of perl jobs newsgroup?
Message-Id: <HlpQc.25448$yT2.8761@clgrps13>

Chris Richmond - MD6-FDC ~ wrote:
> 
>     Our internal news server has a truncated group list, and
> I can't find the proper name for the perl jobs group.  Can
> someone post it please?  I can check for it from home.

perl.jobs

If it is not on your news server you can find it on the server nntp.perl.org


John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Thu, 05 Aug 2004 13:57:48 +0200
From: Tom Regner <regner@dievision.de>
Subject: Re: recursive functions [Silly Joke]
Message-Id: <411220b0$0$5987$4d3ebbfe@news1.pop-hannover.net>

steve_f wrote:
> I could never really wrap my mind around the concept
> of recursive functions. 
That's because: 
To Know Recursion, You Must First Know Recursion...

sorry, couldn't resist
;)
-- 
Dievision GmbH | Kriegerstrasse 44 | 30161 Hannover
Telefon: (0511) 288791-0 | Telefax: (0511) 288791-99
http://www.dievision.de


------------------------------

Date: Thu, 05 Aug 2004 01:35:46 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: recursive functions
Message-Id: <S9gQc.3138$zc4.2924838@news4.srv.hcvlny.cv.net>


"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:ceqvfh$3ot$2@mamenchi.zrz.TU-Berlin.DE...
> Abhinav  <matrix_calling@yahoo.dot.com> wrote in comp.lang.perl.misc:
>
> [recursion]
>
> > Some other examples which might help visualize the idea would be
> >
> > 1. Binary Search
> > 2. Factorial
> > 3. Tower of Hanoi problem
> > 4. Directory search of a file system
> > 5. Depth First Search (DFS) of a (binary) tree
>
> These are good examples, with exception of number 2, which is only
popular.
> I have never quite understood why.
>
> Nothing in multiplying the first few numbers together particularly
invites
> recursion, not any more than adding them up would.  Calculating the
number
> of permutations of n things (which happens to be n!) *is* a naturally
> recursive problem.  Calculating factorials isn't.
>



Recursion provides a way to SPECIFY many functions (including all of
these examples) briefly, yet completely.  Computer languages, which
support recursion, allow us to implement these directly without the
effort to find and validate a non-recursive solution.  We usually pay a
heavy price in both speed and memory for this convenience.

The factorial function belongs on this list because the beginner can
evaluate the pros and cons of both methods.

Bill




------------------------------

Date: 5 Aug 2004 09:09:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: recursive functions
Message-Id: <cesth2$9k1$1@mamenchi.zrz.TU-Berlin.DE>

Bill Smith <wksmith@optonline.net> wrote in comp.lang.perl.misc:
> 
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:ceqvfh$3ot$2@mamenchi.zrz.TU-Berlin.DE...
> > Abhinav  <matrix_calling@yahoo.dot.com> wrote in comp.lang.perl.misc:
> >
> > [recursion]
> >
> > > Some other examples which might help visualize the idea would be
> > >
> > > 1. Binary Search
> > > 2. Factorial
> > > 3. Tower of Hanoi problem
> > > 4. Directory search of a file system
> > > 5. Depth First Search (DFS) of a (binary) tree
> >
> > These are good examples, with exception of number 2, which is only
> popular.
> > I have never quite understood why.
> >
> > Nothing in multiplying the first few numbers together particularly
> invites
> > recursion, not any more than adding them up would.  Calculating the
> number
> > of permutations of n things (which happens to be n!) *is* a naturally
> > recursive problem.  Calculating factorials isn't.
> >
> 
> 
> 
> Recursion provides a way to SPECIFY many functions (including all of
> these examples) briefly, yet completely.

Why would anyone want to specify the factorial recursively?  It's the
product of the first n natural numbers.

>                                           Computer languages, which
> support recursion, allow us to implement these directly without the
> effort to find and validate a non-recursive solution.  We usually pay a
> heavy price in both speed and memory for this convenience.

If the specification isn't recursive, there's no need to find a
non-recursive solution.

> The factorial function belongs on this list because the beginner can
> evaluate the pros and cons of both methods.

It belongs on a second list that demonstrates problems that *can* be
solved recursively, but are better treated otherwise.

Anno


------------------------------

Date: Thu, 05 Aug 2004 13:30:59 +0100
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: recursive functions
Message-Id: <cet9a3$pca$1@news.freedom2surf.net>

In article <cercpd$bn1$1@mamenchi.zrz.TU-Berlin.DE>, "Anno Siegel"
<anno4000@lublin.zrz.tu-berlin.de> wrote:
<SNIP>
>  In everyday programming, the most frequent question about recursion is
> whether to use it at all.  The factorial example teaches the wrong
> decision.

Fair point. Agreed.

> If you want a simple arithmetic example for a naturally recursive
> problem, use Euclid's algorithm.
> 
>     sub euclid {
>         my ( $a, $b) = @_;
>         $b ? euclid( $b, $a % $b) : $a;
>     }
> 

That's beautiful ... noted for future reference

>> computer is not the ideal tool to convert celsius to fahrenheit
either,
>
> Why on earth not? 

the overkill factor ... put another way ... (possibly expensive) claptrap ? ;-)

> Would you prefer a slide-rule?  It isn't used to its

well, when I wrote the above comment, a long strip of paper with 2
columns of marks with numbers next to them was one tool which came to
mind!

>> yet I have written a few programs to do just that when learning a
>> language. :-)
> You weren't taught to do that recursively, I suppose :)

The mind boggles ... ;-)

Rich


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6837
***************************************


home help back first fref pref prev next nref lref last post