Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How would I do this "dig" command in Perl?

by VinsWorldcom (Prior)
on Nov 10, 2015 at 15:03 UTC ( [id://1147363]=note: print w/replies, xml ) Need Help??


in reply to How would I do this "dig" command in Perl?

You can, but with a command line this long (admittedly could be shortened as I'm not the best golfer) - the 'dig' way just seems so much more efficient.

VinsWorldcom@C:\Users\VinsWorldcom> perl -MNet::DNS -e "$r=Net::DNS::R +esolver->new(nameservers=>['resolver1.opendns.com']); $p=$r->send('my +ip.opendns.com'); use Socket qw( inet_ntoa ); print inet_ntoa $p->{an +swer}->[0]->{address};"

Replies are listed 'Best First'.
Re^2: How would I do this "dig" command in Perl? -- another oneliner
by Discipulus (Canon) on Nov 11, 2015 at 08:47 UTC
    ++VinsWorldcom; added to my oneliner list, but a little shortened
    <P> perl -MNet::DNS -MSocket -E "say inet_ntoa(Net::DNS::Resolver->new(na +meservers=>[shift])->send(shift)->{answer}->[0]->{address});" resolve +r1.opendns.com perlmonks.org<P>
    Eventually in the same file there is another quick hack about DNS query using gethostbyname:
    perl -MSocket -e "print map {qq($_ : ).inet_ntoa((gethostbyname$_)[4] +).qq(\n)} @ARGV"

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1147363]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-04-19 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found