Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Mar 2005 06:29:20 +0000 (UTC)
From:      Christopher Nehren <apeiron+usenet@coitusmentis.info>
To:        freebsd-questions@freebsd.org
Subject:   Re: Userland "dig/host" for lookups against /etc/hosts?
Message-ID:  <slrnd4f939.sao.apeiron%2Busenet@prophecy.dyndns.org>
References:  <200503280717.41037@harrymail>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2005-03-28, Emanuel Strobl scribbled these
curious markings:
> Is there one? Unfortunately I can't write one myself, at least not
> in a reasonable amount of time....

- --cut--
#!/usr/bin/perl -w
use strict;

use Socket;
my $host = shift or die "usage: hostshost hostname\n";
my $addr = gethostbyname($host);
die "Cannot resolve host '$host'.\n" unless defined $addr;
my $ip = inet_ntoa($addr);
print "$host has address $ip\n";
- --cut--

Needs some 5.x version of Perl. Works with 5.005_03 as shipped in
FreeBSD 4.x. Also works with more recent perls.

Best Regards,
Christopher Nehren
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (FreeBSD)

iD8DBQFCR6Rpk/lo7zvzJioRAg8pAJ4s69gjARzlc/ZL5sNKT2vSYa9XFwCbBILr
ehnDiO3MuDC3b3nryMUx+Ws=
=Z9c9
-----END PGP SIGNATURE-----

-- 
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated". -- Ken Thompson
If you ask the wrong questions, you get answers like "42" and "God".
Unix is user friendly. However, it isn't idiot friendly.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?slrnd4f939.sao.apeiron%2Busenet>