複数のメニュー方法を使用したデザインスクリプト

複数のメニュー方法を使用したデザインスクリプト

以下のメニュー方法に基づいてbashスクリプトを設計したいと思います。ここで問題は、Cオプションを選択した後、次のメニューが実行されないことです。このメニューを中断せずに、後続のすべてのメニューのすべてのオプションと連携させる代替方法はありますか?

   #!/bin/bash
echo "create_folder"
echo "Select the KPI to be analyse"
echo "A. EXTDB_KPI's"
echo "B. MAP_KPI's"
echo "C. LTE_IMS_SERVICES_KPI's"
read reply

if [ "$reply" != "A" -a "$reply" != "B" -a "$reply" != "C" ]; then
echo "Not valid option: for reply"
exit;
fi;

if [[ $reply == "A" ]]; then
echo "Select the ExtDb KPI to be analyse"
echo "Module:"
echo "A. LTE_Subs_ESM"
echo "B. IMS_Subs_ISM"
echo "C. MTAS_Subs_SDA"
read reply2


if [ "$reply2" != "A" -a "$reply2" != "B" -a "$reply2" != "C" ]; then
echo "Not valid option: for reply2"
fi;

if [[ $reply2 == "A" ]]; then
echo "Select the ExtDb KPI for LTE_Subs_ESM to be analyse"
elif [[ $reply2 == "B" ]]; then
echo "Select the ExtDb KPI for IMS_Subs_ISM to be analyse"
elif [[ $reply2 == "C" ]]; then
echo "Select the ExtDb KPI for MTAS_Subs_SDA to be analyse"
exit;
fi;

elif [[ $reply == "B" ]]; then
echo "Select the MAP_KPI's to be analyse"
echo "Module:"
echo "A. LTE_Subs_ESM"
echo "B. IMS_Subs_ISM"
echo "C. MTAS_Subs_SDA"
read reply3

if [ "$reply3" != "A" -a "$reply3" != "B" -a "$reply3" != "C" ]; then
echo "Not valid option: for reply3"
exit;
fi;

if [[ $reply3 == "A" ]]; then
echo "Select the MAP_KPI's for LTE_Subs_ESM to be analyse"
elif [[ $reply3 == "B" ]]; then
echo "Select the MAP_KPI's for IMS_Subs_ISM to be analyse"
elif [[ $reply3 == "C" ]]; then
echo "Select the MAP_KPI's for MTAS_Subs_SDA to be analyse"
exit;
fi;

elif [[ $reply == "C" ]]; then
echo "Select the LTE_IMS_SERVICES_KPI's  to be analyse"
echo "Module:"
echo "A. LTE_Subs_ESM"
echo "B. IMS_Subs_ISM"
echo "C. MTAS_Subs_SDA"
read reply4

if [ "$reply4" != "A" -a "$reply4" != "B" -a "$reply4" != "C" ]; then
echo "Not valid option: for reply4"
exit;
fi;

if [[ $reply4 == "A" ]]; then
echo "Select the LTE_IMS_SERVICES_KPI's for LTE_Subs_ESM to be analyse"
echo "A. S6a_Interface_KPI's"
echo "B. SWx_Interface_KPI's"
read reply5

if [ "$reply5" != "A" -a "$reply5" != "B" ]; then
echo "Not valid option: for reply5"
exit;
fi;

elif [[ $reply4 == "B" ]]; then
echo "Select the Cx_Interface_KPI's for IMS_Subs_ESM to be analyse"
echo "A. Cx_Multi_Auth_Req"
echo "B. Cx_Regis_Term_Req"
echo "C. Cx_Loc_Info_Req"
echo "D. Cx_Ser_Assign_Req"
echo "E. Cx_User_Auth_Req"
echo "F. Cx_Push_Profile_Req"
echo "G. Ism_Soap"
read reply8


if [ "$reply8" != "A" -a "$reply8" != "B" -a "$reply8" != "C" -a "$reply8" != "D" -a "$reply8" != "E" -a "$reply8" != "F" -a "$reply8" != "G" ]; then
echo "Not valid option: for reply8"
exit;
fi;

if [[ $reply8 == "A" ]]; then
echo "Here is the Cx_Multi_Auth_Req Counters for Cx_Interface_KPI's to be analyse"
elif [[ $reply8 == "B" ]]; then
echo "Here is the Cx_Regis_Term_Req Counters for Cx_Interface_KPI's to be analyse"
elif [[ $reply8 == "C" ]]; then
echo "Here is the Cx_Loc_Info_Req Counters for Cx_Interface_KPI's to be analyse"
elif [[ $reply8 == "D" ]]; then
echo "Here is the Cx_Ser_Assign_Req Counters for Cx_Interface_KPI's to be analyse"
elif [[ $reply8 == "E" ]]; then
echo "Here is the Cx_User_Auth_Req Counters for Cx_Interface_KPI's to be analyse"
elif [[ $reply8 == "F" ]]; then
echo "Here is the Cx_Push_Profile_Req Counters for Cx_Interface_KPI's to be analyse"
elif [[ $reply8 == "G" ]]; then
echo "Here is the Ism_Soap Counters for Cx_Interface_KPI's to be analyse"
exit;
fi;

elif [[ $reply4 == "C" ]]; then
echo "Select the Sh_Interface_KPI's for Subs_Data_Access to be analyse"
echo "A. Sh_Push_Notif_Req"
echo "B. Sh_Usr_Data_Req"
echo "C. Sh_Subs_Notif_Req"
echo "D. Sh_Prof_Upd_Req"
read reply9


if [ "$reply9" != "A" -a "$reply9" != "B" -a "$reply9" != "C" -a "$reply9" != "D" ]; then
echo "Not valid option: for reply9"
exit;
fi;

if [[ $reply9 == "A" ]]; then
echo "Here is the Sh_Push_Notif_Req Counters for Sh_Interface_KPI's to be analyse"
elif [[ $reply9 == "B" ]]; then
echo "Here is the Sh_Usr_Data_Req Counters for Sh_Interface_KPI's to be analyse"
elif [[ $reply9 == "C" ]]; then
echo "Here is the Sh_Subs_Notif_Req Counters for Sh_Interface_KPI's to be analyse"
elif [[ $reply9 == "D" ]]; then
echo "Here is the Sh_Prof_Upd_Req Counters for Sh_Interface_KPI's to be analyse"
exit;
fi;

if [[ $reply5 == "A" ]]; then
echo "Select the S6a_Interface_KPI's for LTE_Subs_ESM to be analyse"
echo "A. Esm_Soap_Notif"
echo "B. S6a_Auth_Info_Req"
echo "C. S6a_Cancel_Loc_Req"
echo "D. S6a_Del_Sub_Data_Req"
echo "E. S6a_Insert_Sub_Req"
echo "F. S6a_Notify_Req"
echo "G. S6a_PurgeUE_Req"
echo "H. S6a_Reset_Req"
echo "I. S6a_Upd_Loc_Req"
read reply6

if [ "$reply6" != "A" -a "$reply6" != "B" -a "$reply6" != "C" -a "$reply6" != "D" -a "$reply6" != "E" -a "$reply6" != "F" -a "$reply6" != "G" -a "$reply6" != "H" -a "$reply6" != "I" ]; then
echo "Not valid option: for reply6"
exit;
fi;

if [[ $reply6 == "A" ]]; then
echo "Here is the Esm_Soap_Notif Counters for S6a_Interface_KPI's to be analyse"
elif [[ $reply6 == "B" ]]; then
echo "Here is the S6a_Auth_Info_Req Counters for S6a_Interface_KPI's to be analyse"
elif [[ $reply6 == "C" ]]; then
echo "Here is the S6a_Cancel_Loc_Req Counters for S6a_Interface_KPI's to be analyse"
elif [[ $reply6 == "D" ]]; then
echo "Here is the S6a_Del_Sub_Data_Req Counters for S6a_Interface_KPI's to be analyse"
elif [[ $reply6 == "E" ]]; then
echo "Here is the S6a_Insert_Sub_Req Counters for S6a_Interface_KPI's to be analyse"
elif [[ $reply6 == "F" ]]; then
echo "Here is the S6a_Notify_Req Counters for S6a_Interface_KPI's to be analyse"
elif [[ $reply6 == "G" ]]; then
echo "Here is the S6a_PurgeUE_Req Counters for S6a_Interface_KPI's to be analyse"
elif [[ $reply6 == "H" ]]; then
echo "Here is the S6a_Reset_Req Counters for S6a_Interface_KPI's to be analyse"
elif [[ $reply6 == "I" ]]; then
echo "Here is the S6a_Upd_Loc_Req Counters for S6a_Interface_KPI's to be analyse"
exit;
fi;

elif [[ $reply5 == "B" ]]; then
echo "Select the SWx_Interface_KPI's for LTE_Subs_ESM to be analyse"
echo "A. SWx_Multi_Auth_Req"
echo "B. SWx_Push_Prof_Req"
echo "C. SWx_Regis_Term_Req"
echo "D. SWx_Server_Assignment_Req"
read reply7


if [ "$reply7" != "A" -a "$reply7" != "B" -a "$reply7" != "C" -a "$reply6" != "D" ]; then
echo "Not valid option: for reply7"
exit;
fi;

if [[ $reply7 == "A" ]]; then
echo "Here is the SWx_Multi_Auth_Req Counters for SWx_Interface_KPI's to be analyse"
elif [[ $reply7 == "B" ]]; then
echo "Here is the SWx_Push_Prof_Req Counters for SWx_Interface_KPI's to be analyse"
elif [[ $reply7 == "C" ]]; then
echo "Here is the SWx_Regis_Term_Req Counters for SWx_Interface_KPI's to be analyse"
elif [[ $reply7 == "D" ]]; then
echo "Here is the SWx_Server_Assignment_Req Counters for SWx_Interface_KPI's to be analyse"
exit;
fi;



exit;
fi;
exit;
fi;
exit;
fi;
echo "MSC BLADEWISE MAIN KPI REPORT,LOG AND SUMMARY ARE UNDER PATH://storage/hss_kpi/$date/"


    Select the KPI to be analyse
A. EXTDB_KPI's
B. MAP_KPI's
C. LTE_IMS_SERVICES_KPI's
C
Select the LTE_IMS_SERVICES_KPI's  to be analyse
Module:
A. LTE_Subs_ESM
B. IMS_Subs_ISM
C. MTAS_Subs_SDA
B
MSC BLADEWISE MAIN KPI REPORT,LOG AND SUMMARY ARE UNDER PATH://storage/hss_kpi/20200519/



答え1

このような

echo "A. EXTDB_KPI's"
echo "B. MAP_KPI's"
echo "C. LTE_IMS_SERVICES_KPI's"
read -p "Select the KPI to be analyse" kpi_resp
case $kpi_resp in
   A) 
      read -p "Select the ExtDb KPI to be analyse" extdb_resp
      case $extdb_resp in
         A) ... ;;
         B) ... ;;
         C) ... ;;
         *) echo "Invalid"; exit ;;
      esac

   B)
      ;;
   C)
      ;;
   *) echo "invalid response"; exit ;;
esac

答え2

貴重なアドバイスありがとうございます。 Select Case ステートメントを使用しました。これで問題が解決しました。


    #!/bin/bash
echo "create_folder"
echo "Select the KPI to be analyse"
select option1 in EXTDB_KPI MAP_KPI LTE_IMS_SERVICES_KPI
do
case $option1 in
EXTDB_KPI)
echo "Select Module to analyse ExtDb KPI"
select option2 in LTE_Subs_ESM IMS_Subs_ISM MTAS_Subs_SDA
do
case $option2 in
LTE_Subs_ESM)
echo "Here is the ExtDb KPI for $option2 to be analyse"
;;
IMS_Subs_ISM)
echo "Here is the ExtDb KPI for $option2 to be analyse"
;;
MTAS_Subs_SDA)
echo "Here is the ExtDb KPI for $option2 to be analyse"
;;
*)
echo "Invalid entry."
break
esac
done
;;
MAP_KPI)
echo "Select Module to analyse $option1"
select option3 in LTE_Subs_ESM IMS_Subs_ISM MTAS_Subs_SDA
do
case $option3 in
LTE_Subs_ESM)
echo "Here is the MAP_KPI for $option3 to be analyse"
;;
IMS_Subs_ISM)
echo "Here is the MAP_KPI for $option3 to be analyse"
;;
MTAS_Subs_SDA)
echo "Here is the MAP_KPI for $option3 to be analyse"
;;
*)
echo "Invalid entry."
break
esac
done
;;
LTE_IMS_SERVICES_KPI)
echo "Select Module to analyse $option1"
select option4 in LTE_Subs_ESM IMS_Subs_ISM MTAS_Subs_SDA
do
case $option4 in
LTE_Subs_ESM)
echo "Select is the LTE_IMS_SERVICES_KPI for $option4 to be analyse"
select option5 in S6a_Interface_KPI SWx_Interface_KPI
do
case $option5 in
S6a_Interface_KPI)
echo "Select is the S6a_Interface_KPI for $option5 to be analyse"
select option6 in Esm_Soap_Notif S6a_Auth_Info_Req S6a_Cancel_Loc_Req S6a_Del_Sub_Data_Req S6a_Insert_Sub_Req S6a_Notify_Req S6a_PurgeUE_Req S6a_Reset_Req S6a_Upd_Loc_Req
do
case $option6 in
Esm_Soap_Notif)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
S6a_Auth_Info_Req)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
S6a_Cancel_Loc_Req)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
S6a_Del_Sub_Data_Req)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
S6a_Insert_Sub_Req)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
S6a_Notify_Req)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
S6a_PurgeUE_Req)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
S6a_Reset_Req)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
Esm_Soap_Notif)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
S6a_Upd_Loc_Req)
echo "Here is the S6a_Interface_KPI for $option6 to be analyse"
;;
*)
echo "Invalid entry."
break
esac
done
;;
SWx_Interface_KPI)
echo "Select is the SWx_Interface_KPI for $option5 to be analyse"
select option7 in SWx_Multi_Auth_Req SWx_Push_Prof_Req SWx_Regis_Term_Req SWx_Server_Assignment_Req
do
case $option7 in
SWx_Multi_Auth_Req)
echo "Here is the SWx_Interface_KPI for $option6 to be analyse"
;;
SWx_Push_Prof_Req)
echo "Here is the SWx_Interface_KPI for $option6 to be analyse"
;;
SWx_Regis_Term_Req)
echo "Here is the SWx_Interface_KPI for $option6 to be analyse"
;;
SWx_Server_Assignment_Req)
echo "Here is the SWx_Interface_KPI for $option6 to be analyse"
;;
*)
echo "Invalid entry."
break
esac
done
;;
*)
break
esac
done
;;
IMS_Subs_ISM)
echo "Select is the LTE_IMS_SERVICES_KPI for $option4 to be analyse"
select option8 in Cx_Multi_Auth_Req Cx_Regis_Term_Req Cx_Loc_Info_Req Cx_Ser_Assign_Req Cx_User_Auth_Req Cx_Push_Profile_Req Ism_Soap
do
case $option8 in
Cx_Multi_Auth_Req)
echo "Here is the Cx_Multi_Auth_Req KPI for $option8 to be analyse"
;;
Cx_Regis_Term_Req)
echo "Here is the Cx_Regis_Term_Req KPI for $option8 to be analyse"
;;
Cx_Loc_Info_Req)
echo "Here is the Cx_Loc_Info_Req KPI for $option8 to be analyse"
;;
Cx_Ser_Assign_Req)
echo "Here is the Cx_Ser_Assign_Req KPI for $option8 to be analyse"
;;
Cx_User_Auth_Req)
echo "Here is the Cx_User_Auth_Req KPI  for $option8 to be analyse"
;;
Cx_Push_Profile_Req)
echo "Here is the Cx_Push_Profile_Req KPI  for $option8 to be analyse"
;;
Ism_Soap)
echo "Here is the Ism_Soap KPI for $option8 to be analyse"
;;
*)
break
esac
done
;;
MTAS_Subs_SDA)
echo "Select  MTAS_Subs_SDA for $option4 to be analyse"
select option9 in Sh_Push_Notif_Req Sh_Usr_Data_Req Sh_Subs_Notif_Req Sh_Prof_Upd_Req
do
case $option9 in
Sh_Push_Notif_Req)
echo "Here is the Sh_Push_Notif_Req KPI  for $option8 to be analyse"
;;
Sh_Usr_Data_Req)
echo "Here is the Sh_Usr_Data_Req KPI  for $option8 to be analyse"
;;
Sh_Subs_Notif_Req)
echo "Here is the Sh_Subs_Notif_Req KPI  for $option8 to be analyse"
;;
Sh_Prof_Upd_Req)
echo "Here is the Sh_Prof_Upd_Req KPI  for $option8 to be analyse"
;;
*)
echo "Invalid entry."
break
esac
done
;;
*)
echo "Invalid entry."
break
;;
esac
done
esac
done


関連情報