#!/bin/ksh ## ## SCRIPT: userids_bystring_bygui ## ## Where: in $FEDIR/scripts where $FEDIR=/apps/nns_com/fea ## ############################################################################ ## PURPOSE: Shows users on this network, selected by string matches ## in 'ypcat passwd' list. ## ############################################################################ ## CALLED BY: 'mailtools' script in $FEDIR/scripts ## and ## CALLED BY: peopletools in $FEDIR/scripts ## actually, by peopletools.chestdef in $FEDIR/scripts. ## ## and originally by ## feamain -> feautils.menu -> feahelpg.menu/who_ps.menu script ## in $FEDIR/scripts. ############################################################################ ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 16Nov2000 Based on 'userids_bystring' script ## Updated by: Blaise Montandon 11jun2002 Added 'Original' to Dept colhead label. ## Updated by: Blaise Montandon 28jul2003 Improved sort and updated trailer ## info in the report file. ############################################################################ if test "$FEDIR" = "" then FEDIR="/apps/nns_com/fea" fi THISHOST=`hostname` ############################################################################## ## GET THE NAME OF THE COMMAND/SCRIPT TO RUN. ############################################################################## WIN_TITLE="Find_SGI_User_Info, $THISHOST, $USER" export WIN_TITLE WIN_INFO="\ Enter a (sub)string by which to search the list of SGI users. Examples: a userid abc00 part of a userid abc last-name o'hara part of last-name hara dept e83 part of dept e8 The search will be CASE IN-SENSITIVE. For example, the string 'e13' will find lines containing the string 'E13' or 'e13'. And the string 'smith' will find lines containing the string 'Smith' or 'smith' or 'SMITH' or ... " export WIN_INFO WIN_PROMPT="String to match:" export WIN_PROMPT ## Optional initialization of entry with a default: WIN_ENTRY="e12" export WIN_ENTRY ## Optional setting of color scheme for the window: WIN_COLOR="lightskyblue" export WIN_COLOR ## FOR TESTING: # set -x STRING2MATCH=`$FEDIR/tkGUIs/enter_at1prompt.tk` ## FOR TESTING: # set - if test "$STRING2MATCH" = "" then exit fi ############################################################################## ## GENERATE THE NAME OF THE OUTPUT-REPORT FILE IN $OUTLIST. ############################################################################## . $FEDIR/scripts/set_localoutlist ############################################################################# ## PREPARE A HEADER FOR THE REPORT. ############################################################################# # THISHOST=`hostname` ## Set above. echo "\ ****************************** `date '+%Y %b %d %a %T%p'` ***************** Users on the SGI network matching string: $STRING2MATCH (The selected lines are grouped by 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. ############################################################################# ## Various extracts of readable/useful fields: # ypcat passwd | cut -d: -f1,3,4,5,6,7 | ... # ypcat passwd | awk ... ## Various sort attempts: # sort -r -t, +1 -2 +0 -1 # sort -t, -k2 -k1 # sort -f -t',' +1 -2 +0 -1 # sort -f -t',' +1b -2b +0 -1 ## DOES NOT HANDLE BLANK BEFORE DEPTID (?). # sort -f -t',' +1.0b -1.8b +0 -1 ## DOES NOT HANDLE BLANK BEFORE DEPTID (?). ypcat passwd | awk -F: \ '{printf "%-9s %6s %6s %-33s %-25s %s\n", $1 , $3 , $4, $5 , $6 , $7}' \ | grep -i "$STRING2MATCH" | sort -f -t',' +1 -2 +0 -1 >> $OUTLIST ############################################################################# ## ADD A TRAILER TO THE REPORT. ############################################################################# echo " ----------------------------------------------------------------------------- The list above was generated by script $0 Command used: ypcat passwd | awk -F: \\ '{printf \"%-9s %6s %6s %-33s %-25s %s\\\n\", \$1 , \$3 , \$4, \$5 , \$6 , \$7}' \\ | grep -i \"$STRING2MATCH\" | sort -f -t',' +1 -2 +0 -1 --- This report-sort extracts from the NIS (Network Information System) login-userids listing of the site SGI network --- the listing as seen via the 'ypcat passwd' command on a client SGI host. --- To TRY to group query results, that involve different department ids, by department, 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. Some records may not sort properly because they were entered with no comma before department-id --- or because they were entered with more than one comma before department-id --- or because they were entered with space between comma and department id. Unfortunately, people who update the 'userid-login file' do not follow a consistent standard in entering user name and department id. --- Most user-departments in the SGI userid-login lookup-file have not been updated since the userid was initially entered in the file. Many users have changed departments since their userid was entered into that file. Hence this report will not give an up-to-date listing of SGI userids in a department --- but it can serve as a starting point for various queries involving department id, userid, and/or user name. --- This report can be generated via site SGI toolchests-drawers: SGI Toolchest -> HandyTools -> sgi-People Tools -> SGIusers BY string-match or SGI Toolchest -> HandyTools -> Mail (& Web) Tools -> nns SGI-USER Queries & Lists -> SGIusers BY string-match ----------------------------------------------------------------------------- " >> $OUTLIST ##################################################################### ## SHOW THE REPORT. ##################################################################### # . $FEDIR/scripts/shofil $OUTLIST (fails to pass $1 if not down a shell) $FEDIR/scripts/shofil $OUTLIST