D
Daniel Berger
Hi,
I'm trying to figure out a way to get the mailhost using the 'resolv'
library, but I'm having trouble because it isn't documented. What's a
good analogue of this Perl script?
use strict;
use Net:
NS;
my $resolv = Net:
NS::Resolver->new();
my $packet = $resolv->search("mailhost");
foreach my $rr ($packet->answer){
$rr->print;
}
# Prints the following (IP addresses changed to protect the guilty):
mailhost.foo.com. 900 IN CNAME mailgate.domain.com.
mailgate.domain.com. 900 IN A 1.2.3.4
mailgate.domain.com. 900 IN A 1.2.3.5
mailgate.domain.com. 900 IN A 1.2.3.6
mailgate.domain.com. 900 IN A 1.2.3.7
mailgate.domain.com. 900 IN A 1.2.3.8
mailgate.domain.com. 900 IN A 1.2.3.9
I'd really just like the first name of the first answer, i.e.
"mailhost.foo.com".
Thanks,
Dan
I'm trying to figure out a way to get the mailhost using the 'resolv'
library, but I'm having trouble because it isn't documented. What's a
good analogue of this Perl script?
use strict;
use Net:
my $resolv = Net:
my $packet = $resolv->search("mailhost");
foreach my $rr ($packet->answer){
$rr->print;
}
# Prints the following (IP addresses changed to protect the guilty):
mailhost.foo.com. 900 IN CNAME mailgate.domain.com.
mailgate.domain.com. 900 IN A 1.2.3.4
mailgate.domain.com. 900 IN A 1.2.3.5
mailgate.domain.com. 900 IN A 1.2.3.6
mailgate.domain.com. 900 IN A 1.2.3.7
mailgate.domain.com. 900 IN A 1.2.3.8
mailgate.domain.com. 900 IN A 1.2.3.9
I'd really just like the first name of the first answer, i.e.
"mailhost.foo.com".
Thanks,
Dan