For the first time the select display the options and it works fine but when I break from screenTwo function to come into this menu (previuos) it ask me for the selection but does not display the options, how can I handle this?
PS3="Please make a selection => " ; export PS3
select var in `awk -F "#" '{print $4}' ${Temp_Config_File} | uniq` PREVIOUS
do
echo "\n`date +"%d%m%Y%H%M%S"` Daemon $var selected " >> $Log_File
if [ -z $var ] ; then echo "\n\tPlease enter a valid choice \n " ; continue
else
if [ $var = "PREVIOUS" ]; then
#removeFiles
break
fi
screenTwo $var
fi
done
First Option : Please give me your idea.
Second option : Capture the return of screenTwo and whenever it is break use awk to print the index with $4. (like below , but I dont like it)
if [ $breakStat -eq 99 ]; then
i=1
echo "\n\nPlease choose one of the following deamon you wish to Start/Stop\n\n"
awk -F "#" '{print $4}' Temp_OPDaemon_Config.cfg | uniq | while read line
do
echo "${i}) ${line}"
let i=i+1
done
echo "${i}) PREVIOUS"
fi
Thanks
this is what I did to handle it .
PS3="Please make a selection => " ; export PS3
select var in `awk -F "#" '{print $4}' ${Temp_Config_File} | uniq` PREVIOUS
do
echo "${Date_Time} Daemon $var selected \n" >> $Log_File
if [ -z $var ] ; then echo "\n\tPlease enter a valid choice \n " ; continue
else
if [ $var = "PREVIOUS" ]; then
#removeFiles
break
fi
while :
do
screenTwo $var
breakStat=$?
if [ $breakStat -eq 99 ]; then
break
elif [ $breakStat -eq 98 ]; then
continue
fi
done
if [ $breakStat -eq 99 ]; then
echo "\n\nPlease choose one of the following deamon you wish to Start/Stop\n\n"
awk -F "#" '{print $4 }' ${Temp_Config_File} | uniq | awk -F "#" '{print NR ") " $0} END {print NR+1") PREVIOUS"}'
fi
fi
done