recursive ypmatch aliases
Daniel P. Kionka
dank at sda.UUCP
Tue Jun 20 14:25:40 AEST 1989
This is a useful utility for sites that have very hierarchial mail
aliases. To find out who is included in an alias, run this script with
the alias name as a parameter. (Multiple alias names will produce
strange results.) In some companies, you can even use the output as a
simple organizational chart.
------------------------------------------------------------------------
#! /bin/sh
# rec-al -- recursive aliases
# ---------------------------
#
# Usage: rec-al alias-name
#
# This program recursively expands mail aliases with "ypmatch". If your
# aliases are not maintained by yellow pages or you do not have the ypmatch
# utility, this program is worthless.
#
# This program runs very slowly, so it is probably best used to create
# a file that you use later. The output is ideal for greps or further
# shell script processing.
#
# It runs slowly because it uses recursive shell scripts and (if I
# understand YP) lots of network calls. A much faster version could be
# written with "ypcat -k aliases" and perhaps awk, if someone wants a
# challenge.
#
# Written by Daniel P. Kionka, released to the public domain.
# Verify parameters
if [ $# -lt 1 ]
then
echo Usage: $0 alias
fi
name=$1
# to reverse the order, remove the shift and make parents="$*"
shift
parents="$* $name"
list=`ypmatch $name aliases 2> /dev/null`
if [ $? -eq 0 ]
then
list=`echo $list | sed 's/,//g'`
for n in $list
do
# Recursive call ...
$0 $n $parents
done
else
# To print the leaves only, use "echo $name"
echo $parents
fi
--
Daniel P. Kionka Cadence Design Systems, Inc.
dank at sda.UUCP San Jose, CA 95134
More information about the Alt.sources
mailing list