[comp.sources.wanted] Want /etc/hosts sorter

jpc@avdms8.msfc.nasa.gov (J. Porter Clark) (02/24/91)

Surely there's something nice and easy to do this with: sort /etc/hosts
in network address order, possibly removing duplicates, possibly
combining hosts with the same address on the same line, etc.  Where do
I find it?  Before I try writing it, that is.
--
J. Porter Clark    jpc@avdms8.msfc.nasa.gov
NASA/MSFC/EB33
Huntsville, AL

david@bacchus.esa.oz.au (David Burren [Athos]) (02/25/91)

In <jpc.667339023@avdms8.msfc.nasa.gov> jpc@avdms8.msfc.nasa.gov (J. Porter Clark) writes:

>Surely there's something nice and easy to do this with: sort /etc/hosts
>in network address order, possibly removing duplicates, possibly
>combining hosts with the same address on the same line, etc.  Where do
>I find it?  Before I try writing it, that is.

Things to watch: addresses on the local network should probably be first
in the sorted list.

Scenario:

A small setup using static routes.
A hosts file with the following entries:

	net.work.1.100	hosta
	net.work.1.101	hostb
	net.work.2.100	hosta
	net.work.2.101	hostc

Hosta is the gateway between the two networks.  On hostc, the command
	/etc/route add net net.work.1 hosta 1
will fail, as "hosta" will be mapped to "net.work.1.100", which we are
trying to set a route to in the first place.

A solution is to add aliases for hosta such as:
	net.work.1.100	hosta hosta-ether
	net.work.2.100	hosta hosta-token
and use the qualified host name in /etc/route commands.


Problems such as this can complicate the implementation of the program
you suggest, which leads me to the following question:

Why do you want to sort your host files?  Cosmetic reasons?  If your
database is so large that you don't want to edit it by hand, or changing
often and thus needing updating across a number of machines, shouldn't
you be using bind or somesuch? (even NIS?)
_____________________________________________________________________________
David Burren [Athos]                          Email: david@bacchus.esa.oz.au
Software Development Engineer                 Phone: +61 3 819 4554
Expert Solutions Australia, Hawthorn, VIC     Fax:   +61 3 819 5580

Disclaimer?  This is just me writing this.  No-one else, got it?