Help me!!!!!shell script question!!!!!!
Here is my script code:
DATE=`/bin/date`
NEW_USERS="/script/userlist"
HOME_BASE="/home/"
cat ${NEW_USERS} | \
while read USER PASSWORD GROUP FULLNAME
do
if [ -z "`grep ^${GROUP}: /etc/group`" ];then
groupadd ${GROUP}
echo "Group ${GROUP} successfully added."
fi
if [ -z "`grep ^${USER}: /etc/passwd`" ]
then
useradd -g ${GROUP} -p ${PASSWORD} -c ${FULLNAME} -m -d ${HOME_BASE}${USER} ${USER}
echo "User ${USER} successfully added."
fi
if [ $? -eq 0 ] ; then
echo "User_fullname:${FULLNAME} Account_name:${USER} user_id:$uid group_name:${GROUP} group_id:$gid $DATE" >> Report
fi
done
This script should be add users from userlist, and then produce user's information to a Report file, my problem is after a user(John) has been added, the information in Report file like this
User_fullname:John Account_name:john user_id: group_name: operation group_id: Tue Mar 23 12:30:28 NZST 2004
But there is no user_id and group_id on it, how could I get these two information, please help me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2 ,another question is if I want to users password that in the userlist must over 6 characters , group name just can be "marketing" "operation" 'business", otherwise they are invaild users. How could I do that, hope my problem is not very difficult!
Last edited by yulitao; 03-22-2004 at 07:16 PM.
|