[net.sources] uucp map lookup scripts

campbell@maynard.UUCP (Larry Campbell) (12/01/85)

Here is a little hack to look nodes up in the uucp map and display their
map entry.  You run 'mkindex' to create an index, then say 'lookup node'
to get the poop on a node.  I usually run mkindex whenever map files arrive.
Simple but useful.  Be sure to edit the definition of MAPDIR in both scripts.

This code is of course not supported or warranted by anyone...  has been
known to cause cancer in laboratory animals...  your mileage may vary.
-----------------------------------cut here-----------------------------------
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	lookup
#	mkindex
sed 's/^X//' << 'SHAR_EOF' > lookup
X: Look up a node in the uucp map database
XMAPDIR=/usr/campbell/Maps/uucp
Xfile=`look $1 $MAPDIR/INDEX | grep "$1": | sed 's/.*://'`
Xif [ "$file" = "" ]
Xthen
X	echo "Can't find $1"
X	exit
Xfi
Xsed -n ":toss
X/#N[ 	]*$1/bcopy
Xd
Xbtoss
X:copy
Xp
Xn
X:copy2
X/^#N/q
Xp
Xn
Xbcopy2" $MAPDIR/$file
SHAR_EOF
sed 's/^X//' << 'SHAR_EOF' > mkindex
X: Make uucp map index for lookup shell script
XMAPDIR=/usr/campbell/Maps/uucp
Xcd $MAPDIR
Xgrep "^#N" *.* | sed 's/	/ /g
Xs/  / /g
Xs/  / /g
Xs/ $//g
Xs/ $//g
Xs/#N //' | awk -F: '	{printf "%s:%s\n", $2, $1}' | sort >INDEX.$$
Xmv INDEX INDEX.OLD
Xmv INDEX.$$ INDEX
SHAR_EOF
exit