#!/bin/ksh ## ## SCRIPT: userids_bydept ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ############################################################################# ## PURPOSE: Shows users on this network, sorted by department. ## Uses 'ypcat passwd' list. ## ############################################################################# ## CALLED BY: peopletools in $FEDIR/scripts ## actually, by peopletools.chestdef in $FEDIR/scripts. ## ## and originally by ## feamain -> feautils.menu -> feahelpg.menu script ## in $FEDIR/scripts ############################################################################# ## MAINTENANCE HISTORY: ## Written by: B. Montandon 5Mar1996 ## Updated by: B. Montandon 16Jan1997 Used awk to improve formatting. ## Updated by: B. Montandon 16Nov2000 Further improved formatting; moved ## 'Command used' to bottom of report. ############################################################################# if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi ############################################################################# ## SET TEMP-LIST-FILENAME IN $OUTLIST. ############################################################################# . $FEDIR/scripts/set_localoutlist ############################################################################# ## PREP REPORT HEADING. ############################################################################# THISHOST=`hostname` echo "\ ***************************** `date '+%Y %b %d %a %T%p %Z'` ***************** Users on the SGI network (GROUPED BY original DEPARTMENT) Note: Most user-departments in the SGI userid-login file have not been updated since the userid was initially entered in the file. Run on Host $THISHOST .............................................................................. User Group 'Original' UserID Num Num User Name , Dept HomeDirectory LoginShell --------- ------ ------ ------------------------- ------------------------- ---------- " > $OUTLIST ############################################################################# ## PREP REPORT CONTENTS. ############################################################################# # ypcat passwd | sort -r -t, +1 -2 +0 -1 | cut -d: -f1,3,4,5,6,7 >> $OUTLIST # ypcat passwd | sort -r -t, +1 -2 +0 -1 | awk -F: \ ypcat passwd | sort -r -t, -k2 -k1 | awk -F: \ '{printf "%-9s %6s %6s %-25s %-25s %s\n", $1 , $3 , $4, $5 , $6 , $7}' \ >> $OUTLIST ############################################################################# ## ADD A TRAILER TO THE REPORT. ############################################################################# echo " ----------------------------------------------------------------------------- The list above was generated by script $0 Command used: ypcat passwd | sort -r -t, -k2 -k1 | awk -F: '{printf "%-9s %6s %6s %-25s %-25s %s\\\n", \$1 , \$3 , \$4, \$5 , \$6 , \$7}' This report-sort assumes that department-id is the first string preceded by a comma (,) in the 'ypcat passwd' listing of the userid-login file. This report can be generated via a 'mailtools' toolchest option, or via old nnsFEAmenu option 'h su' (or 'u h i' or 'u n i' or ' u o i'). ----------------------------------------------------------------------------- " >> $OUTLIST ############################################################################# ## SHOW REPORT FILE. ############################################################################# # . $FEDIR/scripts/shofil $OUTLIST (may fail to pass $1 if not down a shell) $FEDIR/scripts/shofil $OUTLIST