uuhosts

John Quarterman jsq at ut-sally.UUCP
Wed Aug 8 05:42:25 AEST 1984


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 at ut-sally.ARPA, jsq at ut-sally.UUCP, {ihnp4,seismo,ctvax}!ut-sally!jsq



More information about the Comp.sources.unix mailing list