bash菜单列表脚本语法错误

时间:2016-03-01 12:20:38

标签: bash shell

我不明白我的脚本出了什么问题....我的语法错误。最初它没有while开关工作。我添加了while开关,它停止工作,现在即使我删除它也不起作用lulz。

 #!/bin/bash
 ARGS=1
 E_BADARGS=85

 if [ $# -ne "$ARGS" ]
 then
 echo "Usage: `basename $0` <pcap file>"
 exit $E_BADARGS
 fi


{ NUMBER_OF_WHATEVER="$(cmd1)";} 2>/dev/null 

{ NUMBER_OF_WHATEVER2="$(cmd2 | wc | awk {'print $1'})";} 2>/dev/null

{ NUMBER_OF_TCP1="$(cmd3 | wc | awk {'print $1'})";} 2>/dev/null

{ NUMBER_OF_UDP2="$(cmd4| wc | awk {'print $1'})";} 2>/dev/null



HTTP_PERC="$(python -c "print float( ('"${NUMBER_OF_HTTP//\'/\\\'}"'))*100 /     float(('"${NUMBER_OF_TCP//\'/\\\'}"'))   ")"

UDP_PERC="$(python -c "print float( ('"${NUMBER_OF_UDPFLOWS//\'/\\\'}"'))*100 / float(('"${NUMBER_OF_TCP//\'/\\\'}"'))   ")"




echo "$(tput setaf 6) Select Option: "
echo "$(tput setaf 6)1) Analysis1"
echo "2) Analysis2"
echo "3) Test3"
echo "4) Test4 "
echo "5) Test5 "

while true; do
    read -p "Choose Option: " n

    case $n in
    1)  echo "Analysis1"

        echo ""

        echo ""

        echo "=============================================================="
        echo "Pcap File details: "



        echo "=============================================================="


        #echo "Press 1 to return or anything else to exit: ${CHOICE}"

        ;;

    2) echo "Starting Analysis2"

               echo "EOF";; 
    3) echo "Test3"

           printf "\n"

           echo "End of TCP flows";;
    4)  echo "Test4"
        echo "";;

    *)  echo invalid option
    ;;

   esac
 done

0 个答案:

没有答案