Re: How to get IP address of named host?



On Sat, 25 Feb 2006, Gordon Henderson wrote:

getent is a fantastic little command. It will check any system database
and return the necessary data.

Well, thats a new one on me too!

but getent output might be easier to parse than host if
you're using it in a script...

(And I suspect it's also a distro thing - host is present on Debian,
as is getent, but who knows for other distros)

If it uses glibc it will have getent. host, dig and other utilities that
are part of a resolver package on the other hand may well not be present.

In truth there is no single utility that you can be certain will always be
available to you so it's useful to be familiar with several. For scripting
I prefer to use perl - that way I know what's available to me regardless
of where it's running.

Jason
--
UKFSN.ORG Finance Free Software while you surf the 'net
http://www.ukfsn.org/ up to 8Mb ADSL Broadband from just £14.98
http://www.linuxadsl.co.uk/ ADSL Routers from just £21.98

.



Relevant Pages

  • Re: I cant log in except with user root[SOLVED]
    ... When I either try to log into FC5 via the gui or ssh I get an error that says "Access denied for this host". ... I'm pretty sure that I have ldap setup correctly because when I run getent passwd, getent group, getent hosts, and getent shadow I see all of the users, groups, hosts that are in ldap. ... However I don't seam to have all of the default scripts in place because when I login I get bash 3.1 where i expect the host name but that should be easy to fix. ...
    (Fedora)
  • Re: How to get IP address of named host?
    ... This will return the IP and then the host name. ... getent is a fantastic little command. ... but getent output might be easier to parse than host if ... (And I suspect it's also a distro thing - host is present on Debian, ...
    (uk.comp.os.linux)
  • Re: How to get IP address of named host?
    ... This will return the IP and then the host name. ... Heh. ... getent is a fantastic little command. ... and return the necessary data. ...
    (uk.comp.os.linux)