[net.sources] uuhosts

jsq (04/14/83)

Having gotten tired of looking through net.news.map by hand pretty quickly,
I threw together the following hack.  Does anybody have something better?


if test $# -eq 0
then
	echo 'Usage:  '$0' hostname'
	exit 1
fi
cd /usr/spool/news/net.news.map
for arg in $*
do
	sed -n -e "/^Name: ${arg}$/,/^$/p" *
done

kolstad (04/20/83)

#R:ut-ngp:-22500:parsec:42500002:000:3943
parsec!kolstad    Apr 19 10:18:00 1983

I use a slightly more sophisticated scheme that compresses the input data
into position-dependent format (i.e., thus eliminating several hundred
occurrences of the phrase "Name:  " etc).  Here are my procedures with
a few of the first members of the data file.  The only missing program
is comm%.c, which is just like comm except that it stops comparisons
at the first % sign.

					RK

================================
================================
make.roster:
#
# takes its input from file "a" (robbie's universal scratch file)
# a was created by "s"aving mark horton's submissions (out of our notes
# system), hence the removal of *******'s and -----'s.
echo Shaping up a...
xed a  << EOF
g/\*\*\*\*/i\
\

jsq@ut-sally.UUCP (John Quarterman) (12/09/83)

: This is a shar archive.  Extract with sh, not csh.
echo x - uuhosts.1
cat > uuhosts.1 << '!Funky!Stuff!'
.TH UUHOSTS 1L 83/12/08
.SH NAME
uuhosts \- USENET news and UUCP mail information.
.SH SYNOPSIS
.B
uuhosts
hostname ...
.br
.B
uuhosts
-g geographical-region
.br
.B
uuhosts
-g
.SH DESCRIPTION
The \fIuuhosts\fP command is used to look up information about
the configuration of the UUCP mail network and USENET news network
configurations.
.TP
uuhosts hostname ...
for information about a particular UUCP or USENET host or hosts.
The UUCP mail path is given first, followed by the USENET news site information.
Any hosts with names for which the argument is a prefix are shown, e.g.:
.TP
uuhosts ut
gets information about all hosts whose names start with ``ut''.
.TP
uuhosts -g geographical-region
for information about USENET news hosts in a geographical region.
.TP
uuhosts -g Intro
gets an introduction to the USENET news map.
.TP
uuhosts -g Local
gets USENET news site information on the local area.
.TP
uuhosts -g
for a list of known USENET geographical-regions.
.TP
uuhosts
with no arguments gets a short usage message.
.SH FILES
.TP
/usr/local/lib/nmail.paths
UUCP mail path database as produced by \fImkpath\fP and used by \fInmail\fP
(which is called automatically from \fIsendmail\fP on \fIut-sally\fP)
.TP
/usr/local/lib/news/net.news.map
USENET news site information taken from newsgroup \fBnet.news.map\fP
(thanks to \fBcbosgd!map\fP).
.TP
/usr/local/lib/pairs
Raw UUCP mail connection map from \fBparsec!kolstad\fP (thanks again).
.TP
/usr/local/lib/pairs.local
Locally known mail connections.
.SH SEE ALSO
readnews(1), vnews(1), mail(1), nmail(1), sendmail(8)
!Funky!Stuff!
echo x - uuhosts
cat > uuhosts << '!Funky!Stuff!'

LIB=/usr/local/lib
# '@(#) uuhosts 1.6 83/12/08'
if test $# -eq 0
then
	echo 'Usage:	'uuhosts' hostname ...
for information about a particular UUCP or USENET host or hosts, or

	'uuhosts' -g geographical-region
for information about USENET news sites in a geographical region, or

	'uuhosts' -g
for a list of known USENET geographical-regions.
'
	exit 1
fi
paths=$LIB/nmail.paths
# Routing information produced by mkpath for use by nmail.
cd $LIB/news/net.news.map
# This directory should contain the information from newsgroup net.news.map
# that is posted about once a month from cbosgd!map.  The introduction should
# go in a file name Intro, and locally-known information in a file named Local.
if test $1 = -g
then
	shift
	if test $# -eq 0
	then
		ls
		exit 0
	fi
	more $*
	exit 0
fi
for arg in $*
do
	echo UUCP mail path:
	grep '^'${arg} $paths
	echo ""
	echo 'USENET news site information:'
	sed -n -e "/^Name:[ 	]*${arg}/,/^$/p" *
done
!Funky!Stuff!
-- 
John Quarterman, CS Dept., University of Texas, Austin, Texas
{ihnp4,seismo,ctvax}!ut-sally!jsq, jsq@ut-sally.{ARPA,UUCP}

jsq@ut-sally.UUCP (08/07/84)

The bulk of this article is a shar archive that contains a man page
and the Bourne shell source for uuhosts.  Uuhosts is mostly used to
look up UUCP mail paths and USENET news site information, but also
knows how to extract such information from net.news.map and put it
in appropriate directories.  It recognizes both the USENET news map
information from cbosgd!map and also the UUCP mail map information
in the format just posted by seismo!rick.  Of course you still need
to run pathalias on the mail map after you extract the whole map.

Some pathnames in shell variables may need to be adjusted to local
system configurations, but uuhosts should run on most any Version 7
or later Unix system.


: This is a shar archive.  Extract with sh, not csh.
echo x - uuhosts.1
sed -e 's/^X//' > uuhosts.1 << '!Funky!Stuff!'
X.TH UUHOSTS 1L 84/08/04
X.SH NAME
Xuuhosts \- USENET news and UUCP mail information.
X.SH SYNOPSIS
X.B
Xuuhosts
Xhostname ...
X.br
X.B
Xuuhosts
X-g geographical-region
X.br
X.B
Xuuhosts
X-k keyword
X.br
X.B
Xuuhosts
X-g
X.br
X.B
Xuuhosts
X-x
X.SH DESCRIPTION
XThe \fIuuhosts\fP command is used to look up information about
Xthe configurations of the UUCP mail network and the USENET news network.
X.TP
Xuuhosts \fIhostname\fP ...
Xfor information about a particular UUCP or USENET host or hosts.
XThe UUCP mail path is given first, followed by the USENET news site information.
XAny hosts with names for which the argument is a prefix are shown, e.g.:
X.TP
Xuuhosts ut
Xgets information about all hosts whose names start with ``ut''.
X.TP
Xuuhosts -g \fIgeographical-region\fP
Xfor information about USENET news hosts in a geographical region.
X.TP
Xuuhosts -g README
Xgets an introduction to the USENET news map.
X.TP
Xuuhosts -g Local
Xgets USENET news information known only locally.
X.TP
Xuuhosts -g
Xfor a list of known USENET geographical-regions.
X.TP
Xuuhosts -k \fIkeyword\fP
Xfor a list of known USENET sites whose entries contain the word \fIkeyword\fP.
X.TP
Xuuhosts
Xwith no arguments gets a short usage message.
X.SH MAINTENANCE
XIn addition to the options mentioned above, there is
X.TP
Xuuhosts -x
XExtract pieces of the USENET news or UUCP mail maps from a net.news.map article.
X.PP
XThis should be called automatically by a line in \fB/usr/local/lib/news/sys\fP
Xlike
X.IP
Xnewsmap:net.news.map:B:/usr/local/uuhosts -x
X.SH FILES
X.TP
X/usr/local/lib/nmail.paths
XUUCP mail path database as produced by \fIpathalias\fP and used by \fInmail\fP
X(which is called automatically from \fIsendmail\fP on \fIut\-sally\fP)
X.TP
X/usr/local/lib/news/net.news.map
XUSENET news site information taken from newsgroup \fBnet.news.map\fP
X(thanks to \fBcbosgd!map\fP).
X.TP
X/usr/local/lib/news/net.mail.map
XUUCP mail site information taken from newsgroup \fBnet.news.map\fP
X(thanks to the UUCP mapping project).
X.TP
X/usr/local/lib/news/sys
XContains arrangements to call "uuhosts -x".
X.SH SEE ALSO
Xvnews(1), readnews(1), mail(1), sendmail(8)
!Funky!Stuff!
echo x - uuhosts
sed -e 's/^X//' > uuhosts << '!Funky!Stuff!'
X#!/bin/sh
X# '@(#) uuhosts.sh 1.17 84/08/04'
X
X# PATH will have to be adjusted for non-BSD systems.
XPATH=/usr/local:/usr/ucb:/bin:/usr/bin
XLIB=/usr/local/lib
X
X# Routing information produced by pathalias.
Xpaths=$LIB/nmail.paths
X
X# The directory $NEWSMAP should contain the USENET news map information
X# from newsgroup net.news.map that is posted about once a month from
X# cbosgd!map, extracted by a line like this in $LIB/news/sys:
X#
X#	newsmap:net.news.map:B:/usr/local/uuhosts -x
X#
X# Locally-known information should go in $LIB/news/net.news.map/Local.
X# The directory $MAILMAP is extracted by the same command from the
X# UUCP mail information posted to the same newsgroup.
XNEWSMAP=$LIB/news/net.news.map
XMAILMAP=$LIB/news/net.mail.map
Xcd $NEWSMAP
X
Xcase $1 in
X	-x)
X		# extract a new map piece into the map directory
X		temphead=/tmp/maphead.$$
X		temptext=/tmp/maptext.$$
X		awk '
XBEGIN	{
X	temphead = "'$temphead'";
X	isnewsmap = 0; ismailmap = 0;
X	shead = 0; stext = 1; state = shead;
X	print "Reply-To: usenet" >> temphead;
X}
Xstate == shead && /^From: /	{
X	print "Original-" $0 >> temphead;
X}
Xstate == shead && /^Subject: /	{
X	if ($2 != "Re:")
X	for (x = 2; x <= NF; x++) {
X		if ($x == "UUCPmap") {
X			ismailmap = 1;
X			break;
X		}
X		if ($x == "map") {
X			if (x <= 2)
X				continue;
X			x--;
X			if ($x == "USENET") {
X				isnewsmap = 1;
X				break;
X			}
X			if ($x == "UUCP") {
X				ismailmap = 1;
X				break;
X			}
X			x++;
X		}
X	}
X	if (!isnewsmap && !ismailmap) {
X		print "Subject:  not a map update" >> temphead;
X		print "Original-" $0 >> temphead;
X	} else
X		print $0 >> temphead;
X}
Xstate == shead && /^$/		{ state = stext; }
Xstate == stext			{
X	if (isnewsmap != 0)
X		print | "/bin/sh";
X	else if (ismailmap != 0)
X		print | "cd '$MAILMAP'; /bin/sh; ar xv uucpmap.*.ar";
X	else
X		print;
X}
X' > $temptext 2>&1
X		cat $temphead $temptext | /bin/mail usenet
X		rm -f $temphead $temptext
X		exit 0
X	;;
X
X	-g)
X		# by geographical region
X		shift
X		if test $# -eq 0
X		then
X			exec ls
X			exit 1
X		fi
X		exec cat $*
X		exit 1
X	;;
X
X	-k)
X		# by keyword
X		shift
X		exec awk '
XBEGIN		{ inside = 1; outside = 0; state = outside; }
X/^Name:/	{ state = inside; count = 0; useit = 0; }
Xstate == inside	{ block[count++] = $0; }
X/'"$*"'/	{ useit = 1; }
X/^$/ && state == inside	{
X	if (useit == 1) {
X		for (i = 0; i < count; i++) {
X			print block[i];
X		}
X	}
X	state = outside;
X}
X' *
X		exit 1
X	;;
X
X	-*)
X		# unknown option
X	;;
X
X	"")
X		# no arguments
X	;;
X
X	*)
X		# by site name
X		for arg in $*
X		do
X			echo 'UUCP mail path:'
X			grep '^'${arg} $paths
X			echo '
XUSENET news site information:'
X			sed -n -e "/^Name:[ 	]*${arg}/,/^$/p" *
X		done
X		exit 0
X	;;
Xesac
X
Xecho 'Usage:	'uuhosts' hostname ...
Xfor information about a particular UUCP or USENET host or hosts, or
X
X	'uuhosts' -g geographical-region
Xfor information about USENET news sites in a geographical region, or
X
X	'uuhosts' -g
Xfor a list of known USENET geographical-regions.
X'
Xexit 1
!Funky!Stuff!
-- 
John Quarterman, CS Dept., University of Texas, Austin, Texas 78712 USA
jsq@ut-sally.ARPA, jsq@ut-sally.UUCP, {ihnp4,seismo,ctvax}!ut-sally!jsq

jsq@ut-sally.UUCP (John Quarterman) (08/07/84)

Naturally, the next three UUCP map articles in net.news.map were in a
different format.  Here's a revision that will handle all the formats
I've seen used and will also display the information to the user.

: This is a shar archive.  Extract with sh, not csh.
echo x - uuhosts.1
sed -e 's/^X//' > uuhosts.1 << '!Funky!Stuff!'
X.TH UUHOSTS 1L 84/08/04
X.SH NAME
Xuuhosts \- USENET news and UUCP mail information.
X.SH SYNOPSIS
X.B
Xuuhosts
Xhostname ...
X.br
X.B
Xuuhosts
X-g geographical-region
X.br
X.B
Xuuhosts
X-k keyword
X.br
X.B
Xuuhosts
X-g
X.br
X.B
Xuuhosts
X-x
X.SH DESCRIPTION
XThe \fIuuhosts\fP command is used to look up information about
Xthe configurations of the UUCP mail network and the USENET news network.
X.TP
Xuuhosts \fIhostname\fP ...
Xfor information about a particular UUCP or USENET host or hosts.
XThe UUCP mail path is given first, followed by the USENET news site information.
XAny hosts with names for which the argument is a prefix are shown, e.g.:
X.TP
Xuuhosts ut
Xgets information about all hosts whose names start with ``ut''.
X.TP
Xuuhosts -g \fIgeographical-region\fP
Xfor information about USENET news hosts in a geographical region.
X.TP
Xuuhosts -g README
Xgets an introduction to the USENET news map.
X.TP
Xuuhosts -g Local
Xgets USENET news information known only locally.
X.TP
Xuuhosts -g
Xfor a list of known USENET geographical-regions.
X.TP
Xuuhosts -k \fIkeyword\fP
Xfor a list of known USENET sites whose entries contain the word \fIkeyword\fP.
X.TP
Xuuhosts
Xwith no arguments gets a short usage message.
X.SH MAINTENANCE
XIn addition to the options mentioned above, there is
X.TP
Xuuhosts -x
XExtract pieces of the USENET news or UUCP mail maps from a net.news.map article.
X.PP
XThis should be called automatically by a line in \fB/usr/local/lib/news/sys\fP
Xlike
X.IP
Xnewsmap:net.news.map:B:/usr/local/uuhosts -x
X.SH FILES
X.TP
X/usr/local/lib/nmail.paths
XUUCP mail path database as produced by \fIpathalias\fP and used by \fInmail\fP
X(which is called automatically from \fIsendmail\fP on \fIut\-sally\fP)
X.TP
X/usr/local/lib/news/net.news.map
XUSENET news site information taken from newsgroup \fBnet.news.map\fP
X(thanks to \fBcbosgd!map\fP).
X.TP
X/usr/local/lib/news/net.mail.map
XUUCP mail site information taken from newsgroup \fBnet.news.map\fP
X(thanks to the UUCP mapping project).
X.TP
X/usr/local/lib/news/sys
XContains arrangements to call "uuhosts -x".
X.SH SEE ALSO
Xvnews(1), readnews(1), mail(1), sendmail(8)
!Funky!Stuff!
echo x - uuhosts
sed -e 's/^X//' > uuhosts << '!Funky!Stuff!'
X#!/bin/sh
X# '@(#) uuhosts.sh 1.22 84/08/07'
X
X# PATH will have to be adjusted for non-BSD systems.
XPATH=/usr/local:/usr/ucb:/bin:/usr/bin
XLIB=/usr/local/lib
X
X# Routing information produced by pathalias.
Xpaths=$LIB/nmail.paths
X
X# The directory $NEWSMAP should contain the USENET news map information
X# from newsgroup net.news.map that is posted about once a month from
X# cbosgd!map, extracted by a line like this in $LIB/news/sys:
X#
X#	newsmap:net.news.map:B:/usr/local/uuhosts -x
X#
X# Locally-known information should go in $LIB/news/net.news.map/Local.
X# The directory $MAILMAP is extracted by the same command from the
X# UUCP mail information posted to the same newsgroup.
XNEWSMAP=$LIB/news/net.news.map
XMAILMAP=$LIB/news/net.mail.map
Xcd $NEWSMAP
X
Xcase $1 in
X	-x)
X		# extract a new map piece into the map directory
X		temphead=/tmp/maphead.$$
X		temptext=/tmp/maptext.$$
X		awk '
XBEGIN	{
X	temphead = "'$temphead'";
X	isnewsmap = 0; ismailmap = 0;
X	shead = 0; stext = 1; snews = 2; smail = 3; scat = 4; scatting = 5;
X	state = shead;
X	print "Reply-To: usenet" >> temphead;
X}
Xstate == shead && /^From: /	{
X	print "Original-" $0 >> temphead;
X}
Xstate == shead && /^Subject: /	{
X	if ($2 != "Re:")
X	for (x = 2; x <= NF; x++) {
X		if ($x == "UUCPmap" || $x == "uucpmap" || $x == "UUCPMAP") {
X			ismailmap = 1;
X			break;
X		}
X		if ($x == "map" || $x == "Map" || $x == "MAP") {
X			if (x <= 2)
X				continue;
X			x--;
X			if ($x == "USENET") {
X				isnewsmap = 1;
X				break;
X			}
X			if ($x == "UUCP") {
X				ismailmap = 1;
X				break;
X			}
X			x++;
X		}
X	}
X	if (!isnewsmap && !ismailmap) {
X		print "Subject:  not a map update" >> temphead;
X		print "Original-" $0 >> temphead;
X	} else
X		print $0 >> temphead;
X}
Xstate == shead && /^$/	{
X	if (isnewsmap != 0)
X		state = snews;
X	else if (ismailmap != 0) {
X		state = scat;
X	} else
X		state = stext;
X	next;
X}
Xstate == scat	{
X	if ($1 != "cat")
X		state = scatting;
X	else
X		state = smail;
X}
Xstate == scatting {
X	if ($1 == ":")
X		state = smail;
X	else
X		print;
X}
Xstate == smail	{
X	print | "uuhosts -u";
X}
Xstate == snews	{
X	print | "/bin/sh";
X}
Xstate == stext	{
X	print;
X}
X' > $temptext 2>&1
X		cat $temphead $temptext | /bin/mail usenet
X		rm -f $temphead $temptext
X		exit 0
X	;;
X
X	-u)
X		# extract a UUCP map piece
X		cd $MAILMAP
X		/bin/sh
X		for f in *map*.a *map*.ar
X		do
X			ar xv $f
X			rm $f
X		done
X	;;
X
X	-g)
X		# by geographical region
X		shift
X		if test $# -eq 0
X		then
X			exec ls
X			exit 1
X		fi
X		exec cat $*
X		exit 1
X	;;
X
X	-k)
X		# by keyword
X		shift
X		exec awk '
XBEGIN		{ inside = 1; outside = 0; state = outside; }
X/^Name:/	{ state = inside; count = 0; useit = 0; }
Xstate == inside	{ block[count++] = $0; }
X/'"$*"'/	{ useit = 1; }
X/^$/ && state == inside	{
X	if (useit == 1) {
X		for (i = 0; i < count; i++) {
X			print block[i];
X		}
X	}
X	state = outside;
X}
X' *
X		exit 1
X	;;
X
X	-*)
X		# unknown option
X	;;
X
X	"")
X		# no arguments
X	;;
X
X	*)
X		# by site name
X		for arg in $*
X		do
X			echo 'UUCP mail path:'
X			grep '^'${arg} $paths
X			echo '
XUUCP mail host information:'
X			cat $MAILMAP/${arg}* | tr % '\012'
X			echo '
XUSENET news host information:'
X			sed -n -e "/^Name:[ 	]*${arg}/,/^$/p" *
X		done
X		exit 0
X	;;
Xesac
X
Xecho 'Usage:	'uuhosts' hostname ...
Xfor information about a particular UUCP or USENET host or hosts, or
X
X	'uuhosts' -g geographical-region
Xfor information about USENET news sites in a geographical region, or
X
X	'uuhosts' -g
Xfor a list of known USENET geographical-regions.
X'
Xexit 1
!Funky!Stuff!
echo x - shar
sed -e 's/^X//' > shar << '!Funky!Stuff!'
Xseparator='!Funky!Stuff!'
Xecho ': This is a shar archive.  Extract with sh, not csh.'
Xfor f in $*
Xdo
X	echo "echo x - $f"
X	echo "sed -e 's/^X//' > $f << '$separator'"
X	sed -e 's/^/X/' < $f
X	echo "$separator"
Xdone
Xecho "exit"
!Funky!Stuff!
exit
-- 
John Quarterman, CS Dept., University of Texas, Austin, Texas 78712 USA
jsq@ut-sally.ARPA, jsq@ut-sally.UUCP, {ihnp4,seismo,ctvax}!ut-sally!jsq