User Accounts

I have found a script to create user accounts. But there are a few lines i dont understand. Can someone help me with this? Here's the code:

######################################

while [ $TOTAL -gt 0 ];
do
ACCT=${USER_ACCT}${START}
START=`expr $START + 1`
START=`echo ${START} | awk '{printf("%02d",$1)}'`
TOTAL=`expr $TOTAL - 1`
useradd -g ${GROUP_ID} -d ${TOP_LEVEL_DIR}/${ACCT} -c 'Student Acct' -m -s /bin/ksh ${ACCT}
(cd ${TOP_LEVEL_DIR}/coursefiles; tar cf - . | (cd ${TOP_LEVEL_DIR}/${ACCT}; tar xf -))
chown -R ${ACCT} ${TOP_LEVEL_DIR}/${ACCT}
chgrp -R ${GROUP_ID} ${TOP_LEVEL_DIR}/${ACCT}
chmod 755 ${TOP_LEVEL_DIR}/${ACCT}
echo "Account ${ACCT} created."
echo
done

ACCT=${USER_ACCT}${START_SAV}
echo "Enter the default password to use for the recently created accounts"
echo
passwd ${ACCT}
PASSWORD=`grep '^'${ACCT}':' /etc/shadow |cut -d: -f2`

START=`expr $START_SAV + 1`
START=`echo ${START} | awk '{printf("%02d",$1)}'`
TOTAL=`expr $TOTAL_SAV - 1`

while [ $TOTAL -gt 0 ];
do
ACCT=${USER_ACCT}${START}
ed /etc/shadow <<EOF
g/${ACCT}:/s/:\*LK\*:/:${PASSWORD}:
W
Q
EOF
START=`expr $START + 1`
START=`echo ${START} | awk '{printf("%02d",$1)}'`
TOTAL=`expr $TOTAL - 1`
done

######################################

Thanks!!!

Is this homework, Sensor?

Which part(s) exactly do you want to know about? The "while .... done" parts are loops. Most of the code you listed is assigning values to variables and running commands that you could easily figure out by typing "man chown", "man chmod", etc at a prompt.

The Do while loops & the echo's i really understand, i'm not that stupid :eek:
I just want to know what the 2 bloks do...

1) you dont have do while loops. you only have while loops. (at least in your script.)

2) from a glance at the commands and files used you are createing user and setting up their passwords.

you will understand the script alot more if you read the man pages for the commands used.