Hi guys, I have a piece of snippet below which asks the user to input some numbers
if isDatasubEnabled && isReconEnabled; then
echo "1 = CGT, 2 = Subscriber, 3 = Order Monitor, 4 = Revaluations, 5 = Reconciliation, 6 = All, 7 = Exit"
elif isDatasubEnabled && isReconEnabled=0; then
echo "1 = CGT, 2 = Subscriber, 3 = Order Monitor, 4 = Revaluations, 6 = All, 7 = Exit"
elif isDatasubEnabled=0 && isReconEnabled; then
echo "1 = CGT, 3 = Order Monitor, 4 = Revaluations, 5 = Reconciliation, 6 = All, 7 = Exit"
else
echo "1 = CGT, 3 = Order Monitor, 4 = Revaluations, 6 = All, 7 = Exit"
fi
read daemonOption
i=1
if [ "$daemonOption" = '7' ] ; then
return
fi
if [ "$daemonOption" = "" ] ; then
echo "Error..."
stop_daemons;
return
else
daemonLength=`expr length $daemonOption`
while [ "$i" -lt $daemonLength+1 ]
do
substring=`expr substr $daemonOption $i 1`
if [ "$substring" != '1' ] && [ "$substring" != '2' ] && [ "$substring" != '3' ] && [ "$substring" != '4' ] && [ "$substring" != '5' ] && [ "$substring" != '6' ]
then
echo "Error..."
stop_daemons;
return
fi
let i++
done
fi
The problem with the above is for example:
if datasub and recon are both off, then the user will see the following
echo "1 = CGT, 3 = Order Monitor, 4 = Revaluations, 6 = All, 7 = Exit"
But the user can still enter the number 2 or 5, which is not right
I need some way of only allowing the user to enter the numbers that are on the menu, any ideas guys?