0

第一次选择显示选项,它工作正常,但是当我从 screenTwo 功能中断进入这个菜单(previuos)时,它要求我选择但不显示选项,我该如何处理?

 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

第一个选项:请给我你的想法。

第二个选项:捕获 screenTwo 的返回,每当它中断时,使用 awk 以 $4 打印索引。(如下所示,但我不喜欢它)

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

谢谢

4

1 回答 1

1

这就是我为处理它所做的。

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
于 2012-04-05T07:06:07.743 回答