unix scripting help urgent help

hi, i have a script but i cant get it to work properl. can someone please help me... it will be appreciated. the file goes as if there are five options to selected and it performs its task that has been assgned and 5th option is for exit and that works but i cant get 4 options to work properly.

the first arguments don matther becasuse its not being used. I starts with argument 4 at the bottom where it said menu option backup file, and add new users but they dont seem to work...

#
# Description
# ----
#description: basic input, basic output with agrumentsDisplay new blank line.
#checks if agruments are missing or invalid
#checks if file exist for input
#checks if file exist for output if not then create new file
# prints output and agruments with process error

# no arguments present at all.
echo

# No arguments provided on command line
if [ "$#" = "0" ]
then
echo "No arguments provided on command line. "
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo
exit 10
fi

# Test too many arguments
# arguments greater >4
if [ "$#" -ge "5" ]
then
echo "Too many arguments provided on command line. "
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo

exit 18
fi

# Test to see the first targuments
if [ "$1" = "" ]
then
echo "First argument missing. "
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo
exit 12
else

if [ "$1" != "-i" ]
then echo
echo "Error: Expecting \"-i\" for the first argument."
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo
exit 13
fi
fi

# Test to see the arguments
if [ "$2" = "" ]
then
echo "Second argument missing."
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo
exit 14
else
if [ ! -e "$2" ]
then echo
echo "Error: File $2 does not exist."
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo
exit 15
fi
fi

# Test to see the third arguments
if [ "$3" = "" ]
then
echo "Third argument missing."
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo
exit 16
else
if [ "$3" != "-o" ]
then echo
echo "Error: Expecting \"-o\" for the third argument."
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo 17
exit
fi
fi

#Test to see the fourth arguments
#argument missing
if [ "$4" = "" ]
then
echo "Main Menu"
echo
echo "Usage: ./Lab_14.sh -i <infile> -o <outfile>"
echo " -i <infile> The filename containing the existing data."
echo " -o <outfile> The filename you want the output to go to."
echo

fi

# Test all four arguments
if [ "$#" = "4" ]
then
echo "Message: File \"$4\" exist already."
echo -n "Do you wish to overwrite the contents? (y/n) "
read key_in
if [ "$key_in" = "n" ]
then
echo
echo "No overwrite has been selected. Exiting script.."
echo
echo -n "Press <Enter> to clear the screen "
read key_in
clear
exit 19
fi
fi

##### starts here, need help on this code at bottom##############

# comments::
#if [ -e "$4" ]
#then
#if it does not exist, show menu option
#then
#echo "ok"
# else exit the script
#fi
# comments

# A user has been asked to enter one of the menu, and will starts looping

clear
echo " Main Menu"
echo " ---"

echo "1)backup file "


echo "2) report total amount of users"

echo "3) users currently logged online"

echo "4) add new users"
echo
echo "5) Exit 5"


echo
echo -n "Please enter a menu option: "
read key_in

# read key in
# while do loop, stops at menu option five
while
[ "$key_in" -ne "5" ]
do
case $key_in in

1)
echo "Manu option \"$key_in\" selected"
cp $2 $4
echo -e " backup of original file \"$2\" completed "
echo -e " backup filename is: \"$4\"\n";;

2)
echo "Main option \"$key_in\" selected"
user= "who | wc -l"
echo " there are " \($user \) "users online"
echo;;

3)
echo "Menu option \"$key_in\" selected"
db = "wc -l /etc/passwd | cut -d" " -f6"
echo " there are " \( $db \) " users in the databse"
echo;;

4)
echo "Main option \"$key_in\" selected"
echo -n " Enter name: "
read name
echo -n " Enter password: "
read pass
echo -n " Enter userid (UID): "
read uid
echo -n " Enter groupid (GID): "
read gid
echo -n " Enter full name (GECOS) : "
read full
echo -n " Enter home directory (absolute ref): "
read home_dir
echo -n " Enter shell to run (absolute ref): "
read shell
profile= "$name $pass $uid $gid $full $home_dir $shell "
echo $profile >> $4
echo;;

5)
echo "main option \"$key_in\"selected";;

esac

please enter a menu option below
echo -n " Press <Enter> to continue ... "
read key_in
clear
echo " Main Manu"
echo " ---"
echo " 1) backup original file"
echo " 2) report total amount of users "
echo " 3) users currently logged on"
echo " 4) enter a new user"
echo
echo " 5) Exit "
echo
echo -n " Please enter menu option: "
read key_in
echo

done

# End of script
[7712 byte] By [sukhi5710] at [2007-11-20 9:49:16]