Im new to unix/linux and am having trouble with this one.
My problem is when i enter 9 to exit it doesnt do so.
also option 6 doesent display the time. Its getting to be frustrating.
I know there are probably alot of bug in this bu these basic ones are really odd.
#!bin/bash
#
until [ "$userIn" = "10" ] #User controllerd until <9> is entered
or main menu
do
clear
echo "Welcome to Christopher Krause's Main Menu"
echo
echo "1: Users Curretnly Logged On "
echo "2: Display Calender for chosen Month and Year"
echo "3: Diplay Current Directory Path"
echo "4: Change Directory"
echo "5: List of Files in Current Directory "
echo "6: Display Current Time & Date & Calendar "
echo "7: Start the vi editor "
echo "8: Email a file to a user "
echo "9: Quit "
echo
echo -n "Please enter your option and hit <Enter>: " #User prompt
read userIn #Storing available directory
case "$userIn" in #Users input
1) clear
echo
echo "Users Curretnly Logged In:"
who | cut -d\ -f1
#Program description
echo "Press <Enter> to return to menu"
read null
;;
2) clear
echo -n "Plese enter the month in the form MM:"
#
read month
if [ $month -lt 1 -o $month -gt 12 ]
then
echo "$month is not a valid month!!"
else
echo -n "Please enter a yeat in the form of YYYY: "
read year
if [ $year -lt 0 -o $year -gt 3000 ]
then
echo "$year is not a valid year!!"
else
cal $month $year
fi
fi
echo
echo "press <Enter> to return to main menu."
read null
;;
3) clear
echo "Your directory path is: "
echo
pwd #pwd command is intiated and displayed
echo "press <Enter> to return to main menu."
read null
;;
4) clear
echo -n " Enter new directroy path."
read userdir
if [ $userdir ]
then
cd $userdir
elif [ -z $userdir ]
then
cd ~
elif [ $userdir = "~" ]
then
cd ~
elif [ $userdir = "/$HOME"
then
cd ~
else
echo "$userdir is not a valid directory!!"
echo
echo "press <Enter> to go to main menu."
read null
fi
;;
5) clear
ls -l | more
echo
echo "press <Enter> to return to main menu."
echo
;;
6) clear
echo -n "The current date and time is: "
echo
date
echo
echo "press <Enter> to return to main menu."
;;
7) clear
echo "Please enter the file you want to edit."
echo "{Leave blank for new file}"
echo
echo -n "File: "
read vifile #Valid file is stored
filetype='file "$vifile" | cut -d\ -f2'
if [ $filetype = "ASCII" ]
then
vi $vifile
elif [ $filetyoe = "cannot" ]
then
vi $vifile
elif [ -z $vifile ]
then
vi
else "$vifile is not a valid text file."
fi
echo
echo "press <Enter> to return to main menu."
read null
;;
8) clear
validuser=1
until [ $validuser -eq 0 ]
do
echo -n "Please enter the recipients name and press <Enter>."
read emailname
cat /etc/passwd | cut -d: -f1 | grep $emailname 1> /etc
if [ $7 -eq 0 ]
then
validuser=0
else echo "$emailname is not a valid user on 'hostname'"
fi
done
echo -n Please enter the subject of email and press <Enter>."
read emailsubject
done
validfile=1
until [ $validfile -eq 0 ]
do
echo -n "Please enter the file to be attached and press <Enter>."
read emailfile
validfile='file "$emailfile" | cut -d\ -f2'
if [$validfile = "ASCII" ]
then
validfile=0
else
echo "$emailfile is not a text file!!!"
fi
done
'mail -s "$emailsubject" "$emailuser" < "$emailfile"'
;
9) echo
echo "You have chosen to quit. Goodbye!!!"
exit 1
;;
*) echo
echo ""$userIn" is not a valid option. Please try again."
echo
echo "
;;
esac
done
