I am writting my 1st shell script and it has problems exiting correctly and the else statement is suppose to display an error message if the menu choice entered is invalid but it does not. I have cut and pasted it below, please help:
#!/bin/bash
# MENU DRIVEN BASH SCRIPT CREATED BY ERIC BISHOP (ebishop@cox.net) FOR GWCC LINUX CLASS
# CREATED ON NOVEMBER 25th 2002
# ISSUED UNDER THE GNU GPL (GNU GPL KICKS ASS!!)
# I WOULD LIKE TO GIVE CREDIT TO THE LINUX DOCUMENTATION PROJECT
# BECAUSE THEY HAD SAMPLE CODE FOR ME TO WORK OFF OF!
# (
http://en.tldp.org/HOWTO/Bash-Prog-I...O-9.html#ss9.1)
RELEASE=/etc/redhat-release
clear
echo
echo "Hello $USER, Welcome to the CONTROL MENU"
echo "The Date & Time is:"
date
echo
echo "Please enter a selection number below and press the ENTER key"
echo
OPTIONS="Free-Disk-Space View-Kernel-Version View-XFree86-Version View-Distribution-Version View-System-Uptime-Status Test-Network-Card Quit"
select opt in $OPTIONS; do
if [ "$opt" = "Quit" ]; then
echo
echo "THANKS FOR USING MY SCRIPT"
echo "FEEL FREE TO MODIFY IT TO SUIT YOUR NEEDS"
echo
echo "TO EXIT, YOU MAY NEED TO PRESS CTRL+Z"
exit
fi
if [ "$opt" = "View-Kernel-Version" ]; then
echo
echo "This System is powered by Kernel Version:"
echo
uname -r
echo
echo "Press the ENTER key to go back to the CONTROL MENU"
read
echo
./assignment.sh
fi
if [ "$opt" = "View-Distribution-Version" ]; then
echo
echo "This System Distribution is:"
echo
cat $RELEASE
echo
echo "Press the ENTER key to go back to the CONTROL MENU"
read
echo
./assignment.sh
fi
if [ "$opt" = "Test-Network-Card" ]; then
echo
echo "Testing results of your network card is:"
echo
ping 127.0.0.1 -c 5
echo
echo "Press the ENTER key to go back to the CONTROL MENU"
read
echo
./assignment.sh
fi
if [ "$opt" = "View-System-Uptime-Status" ]; then
echo
echo "This System Has been running for:"
echo
uptime
echo
echo "Press the ENTER key to go back to the CONTROL MENU"
read
echo
./assignment.sh
fi
if [ "$opt" = "View-XFree86-Version" ]; then
echo
echo "This System has the following XFree86 Version Installed:"
echo "(SHOWS ALL CORRESPONDING XFree86 FILES!)"
echo
rpm -qa |grep XFree86
echo
echo "Press the ENTER key to go back to the CONTROL MENU"
read
echo
./assignment.sh
fi
if [ "$opt" = "Free-Disk-Space" ]; then
echo
echo "The free space on this systems hard disks is:"
echo
df -h
echo
echo "Press the ENTER key to go back to the CONTROL MENU"
read
echo
./assignment.sh
else
clear
echo INVALID SELECTION, PLEASE TRY AGAIN
./assignment.sh
fi
done