i want to get user input like this
please tell which option to chose
1. mango 2. tango 3. rango
if user chooses mango
then it should execute a set of statements and again ask like this
what do you want to do
1.add 2.subtract 3.exit
when i choose exit it should goto my previous menu asking again (please tell which option to chose
1. mango 2. tango 3. rango )
Please specify how to do this
i have did skeleton coding to an extent like this
#!/usr/bin/ksh
echo -e -n "\n Specify the script to be run \n specify the names as listed in the below format \n 1. mango 2. tango 3. rango 4.exit"
read answer
echo "$answer"
while true
do
case $answer in
mango) echo "########################################################################## #########"
DT=$(date)
echo "******************* $DT ***********************"
echo -e "\n Specify what you want to do from the below options \n 1.add \n 2.subtract \n 3.exit"
read input
if [ "add" = "$input" ]
then
echo "add"
elif [ "exit" = "$input" ]
then
elif [ "subtract" = "$input" ]
else
echo "!! must specify add or subtract" read ;;
fi
tango) echo "tango"
break;;
rango) echo "rango"
break;;
exit) exit 0 ;;
break;;
*) echo "please enter correct value" read ;;
break;;
As you can see first it will ask me to choose from 6 options
1. mango 2. tango 3. rango 4.exit
. If for example if i type "mango"
then it will ask
1.add 2.subtract 3.exit
now if i type "exit" . it should go back to main menu (THIS IS WHAT IAM NOT ABLE TO DO) and ask
1. mango 2. tango 3. rango 4.exit
if i give exit here then only script should exit.
Please help how to do this one in the existing script. I have just put an skeleton overview of the script. If anyone have any better approach on this then please help me arrive to this solution. Please help me sooner. As it is very very much urgent