Mkpairs.sh: uucp data to path pairs
ajs at hpfcla.UUCP
ajs at hpfcla.UUCP
Fri Jun 8 04:06:00 AEST 1984
If you use pathalias or equivalent and would like a way to use the data
posted to net.news.map, here is a script that helps. Unpack the data
files from that newsgroup, then run this script with them as arguments.
Standard output is a sorted, unique list of connection pairs. Enjoy,
and no flames please about lack of a manual entry.
Alan Silverstein, hpfcla!ajs
PS: I assume somebody already has something like this but I haven't
heard of it. If so, please mail me, perhaps we could converge them.
------- mkpairs.sh ---------
# Script to extract connection pairs from uucp data base(s).
# Usage: <script> [files...]
# Does a hardwired pathname by default.
# Sorts and uniqs the data so pathalias likes it.
# Has to do things the hard way since some USENET data is not
# simple, e.g. there are unexpected fields around News and Mail,
# or News or Mail is missing.
# Initialize:
PATH=/bin:/usr/bin
tab=" "
data=xxx # default file.
if [ $# = 0 ] # no args given.
then
opt=$data # else it's null.
fi
# Do all arguments, else the hardwired filename:
for file in $* $opt
do
# Process the data base into a series of output lines:
#
# The awk keeps the nodename for each line until the next Name line.
# It notes the first News or Mail line and processes data until a line
# that has fields and doesn't start with white space.
# Unfortunately, changing NF erases $0, so it has to handle specially
# cases where $1 was erased.
awk < $file '
/^Name:/ {
nodename = $2; # save nodename.
}
/^News:/ || /^Mail:/ {
$1 = ""; # start of line is space.
print $0 > "/dev/null"; # force rebuilding of $0.
flag = 1; # and enter next section.
}
/^'"$tab"'/ || /^ / {
if (NF && flag) # time to process data.
{
split ($0, f);
for (field = 1; field <= NF; field++)
if (f[field] != "") # NF might be too big.
printf ("%s\t%s\n", nodename, f[field]);
next; # leave flag set.
}
}
{
flag = 0; # clear flag.
}
'
done |
sort |
uniq
More information about the Comp.sources.unix
mailing list