Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!agate!bionet!ames!hc!pprg.unm.edu!unmvax!nmtsun!ucsd!sdcsvax!ucsdhub!hp-sdd!hplabs!hpda!sda!dank From: dank@sda.UUCP (Daniel P. Kionka) Newsgroups: alt.sources Subject: recursive ypmatch aliases Message-ID: <276@sda.UUCP> Date: 20 Jun 89 04:25:40 GMT Reply-To: dank@sda.UUCP (Daniel P. Kionka) Distribution: alt Organization: Cadence Design Systems, San Jose Lines: 58 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@sda.UUCP San Jose, CA 95134