David Lee wrote:
On Fri, 2 Dec 2005, Alan Robertson wrote:
Horms wrote:
[...]
I think it would be better to write a small c programme that exposes
gethostbyname as a shell command. This would honour the previling
nsswitch.conf and let libc worry about the details.
Something like the code below. Sorry its a bit over engineered,
I pieced it from code I had lying around the house.
I don't think that anything complex is needed. This is only test code,
and it's never going to use this to contact the machines - just to
figure out if the names given are valid. If they're found in
/etc/hosts, OR in DNS, it's all good. It won't cover those people who
might be using yellow pages or something like that. But, I really don't
care about that case for testing (which is all this code is good for).
(I'm coming at this as an outsider, so may be missing a point or two.)
This sounds like the "getent" command:
getent <database> <key>
e.g.
getent hosts hostname
and this automatically takes account of "nsswitch.conf" data sources
(files, NIS (formerly know as "Yellow Pages"), DNS, ...).
This command is available on both Linux and Solaris, although not (it
seems(*)) on *BSD.
If "getent" is an appropriate solution in principle, then one possible way
forward is to use that, and provide our own equivalent (sh?, perl?) for
those OSes which lack it. (Probably not perfect, but might it be
adequate?)
I didn't realize that getent exists. But, really, the need here is
extremely low tech, and being a little over-generous in success is fine.
Maybe try getent, if it doesn't exist, then grep /etc/hosts, and if
that fails, try host command (or nslookup, or whatever).
--
Alan Robertson <[EMAIL PROTECTED]>
"Openness is the foundation and preservative of friendship... Let me
claim from you at all times your undisguised opinions." - William
Wilberforce
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/