From owner-freebsd-current Thu May 9 7:58:47 2002 Delivered-To: freebsd-current@freebsd.org Received: from web20904.mail.yahoo.com (web20904.mail.yahoo.com [216.136.226.226]) by hub.freebsd.org (Postfix) with SMTP id 97C1C37B40C for ; Thu, 9 May 2002 07:58:39 -0700 (PDT) Message-ID: <20020509145839.71143.qmail@web20904.mail.yahoo.com> Received: from [218.108.155.178] by web20904.mail.yahoo.com via HTTP; Thu, 09 May 2002 07:58:39 PDT Date: Thu, 9 May 2002 07:58:39 -0700 (PDT) From: David Xu Subject: Re: Perl scripts that need rewiting - Any volunteers? (rmuser shell script ready) To: current@freebsd.org, Mark Murray MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0-2129547160-1020956319=:70351" Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --0-2129547160-1020956319=:70351 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline here is the rmuser program written in SHELL script. I have spent one hour on writting it down and tested. please see attached. David __________________________________________________ Do You Yahoo!? Yahoo! Shopping - Mother's Day is May 12th! http://shopping.yahoo.com --0-2129547160-1020956319=:70351 Content-Type: text/plain; name=rmuser Content-Description: rmuser Content-Disposition: inline; filename=rmuser #! /bin/sh PW=/usr/sbin/pw usage() { echo "$0 [-y] [username]" exit 1 } if [ $# -gt 2 ]; then usage exit 1 fi confirm=1 if [ $# -eq 2 ]; then case $1 in [-][y]) confirm=0 ;; *) usage esac shift; fi if [ $# -eq 1 ]; then user=$1 else while true do echo -n 'Enter login name for user to remove: ' read user case $user in "") ;; *) $PW usershow $user > /dev/null 2>&1 if [ $? -eq 0 ]; then break; else echo 'Sorry, login name not in password database.' fi ;; esac done fi rmhome='-r' if [ $confirm -eq 1 ]; then echo 'Matching password entry:' echo $PW usershow $user if [ $? -ne 0 ]; then exit 1 fi echo echo -n 'Is this the entry you wish to remove? ' read y case $y in [yY]) ;; *) echo "$0: Informational: User $user not removed." exit 0 ;; esac home=`$PW usershow $user | /usr/bin/cut -f 9 -d ':'` echo -n "Remove user's home directory ($home)? " read y case $y in [Yy]) ;; *) rmhome='' ;; esac fi echo /usr/bin/killall -KILL -u $user | su -m $user >/dev/null 2>&1 $PW userdel $user $rmhome if [ $? -eq 0 ]; then echo "User account $user removed" #else expect pw already reported error fi --0-2129547160-1020956319=:70351-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message