#
#####Message Texts ######
set mesg1 = "Please enter the logon ID of the user to be added:"
set mesg2a = "Logon ID "
set mesg2b = " is already taken, please select another."
set mesg3 = "Please enter a numeric id number (default is "
set mesg4a = "User id number"
set mesg4b = "is already taken, please select another."
set mesg5 = "Please enter a numeric group id number (default is 10):"
set mesg6 = "Please enter user's real name and any other pertinent data:"
set mesg7a = "Please specify a login directory (default is /n/"
set mesg7b = "): "
set mesg8 = "Please specify a shell environment (default is /bin/csh):"
set mesg9 = "These are pending additions to /etc/passwd."
set mesg10 = "Press <ret> to continue, <ctrl c> to abort."
#########################
						# get unique login name 
echo -n $mesg1' '
scanname:
set name = ($<)
if ($#name == 0) then
	goto scanname
endif
						# check name for uniqueness
awk '{FS=":"} {print $1}' /etc/passwd > foo
fgrep -xs $name foo
if ($status != 1) then
	echo -n $mesg2a $name $mesg2b' '
	goto scanname
endif

awk '{FS=":"} {print $3}' /etc/passwd > foo
set i = 2
loop:
	fgrep -xs $i foo
	if ($status != 1) then
		set i = `expr $i + 1`
		goto loop
	endif	# not reached

						# get unique login number 
echo -n $mesg3$i$mesg7b
scanuid:
set uid = ($<)
if ($#uid == 0) then
	set uid = $i
endif
						# check uid for uniqueness
fgrep -xs $uid foo
if ($status != 1) then
	echo -n $mesg4a $uid $mesg4b' '
	goto scanuid
endif
						# get group number 
echo -n $mesg5' '
set gid = ($<)
if ($#gid == 0) then
	set gid = '10'
endif
						# get personal data
echo $mesg6' '
set real_name = ($<)
						# get login directory
echo -n $mesg7a$name$mesg7b' '
set log_dir = ($<)
if ($#log_dir == 0) then
	set log_dir = '/n/'$name
endif
						# get login shell
echo -n $mesg8' '
set shell = ($<)
if ($#shell == 0) then
	set shell = '/bin/csh'
endif
						# show pending changes
echo ' '
echo ' '
echo $mesg9
echo ' '
echo "Logon ID: 		" $name
echo "ID Number: 		" $uid
echo "Group ID Number: 	" $gid
echo "Real Name: 		" $real_name
echo "Login Directory:	" $log_dir
echo "Shell Environment:	" $shell
echo ' '
echo -n $mesg10
set abort = ($<)
if ($#abort != 0) then
  	exit(1)
endif
/bin/rm -f foo
