I have several scripts which require the utility
getent. In addition, I've read several handy tips which use getent.
getent is a Networking utility which is widely available on Unix, *BSD and Linux-based systems. This tool is commonly used by Sysadmins and power users to lookup network information (IP addresses, etc). As far as hostnames go,
getent is one of the few tools which use both
/etc/hosts and DNS.
As Wikipedia says:
getent is a unix command that helps a user get entries in a number of important text files called databases.
The important thing here is that
getent will search the same name services in the same order as would most applications on a unix-like system. This makes it invaluable when debugging system or application trouble.
nslookup specifically look at DNS only, while
dscl expects you to spell out the name services you want to search.
I would like to use
getent for two testcases:
/etc/hostsbefore querying DNS. For example, if I add
getent hosts testhost.example.orgshould use the entry from
/etc/hostsbefore querying DNS.
MacPorts does not seem to provide a package providing
getent exist on Snow Leopard?