任何机构都可以帮助我解决这个问题
我的狂欢是
#!/bin/bash
#Setup Scripts Project v1.0
#By me
#===============================================
dialog --backtitle "Setup Scripts "
--title "[Main Menu]"
--menu "You can use the UP/DOWN arrow keys, Or the number keys 1-9 to choose an option.n
Choose the option" 18 70 8
Setup "Start Setup And Secure this Server"
Nginx_Setup "Install Nginx"
Anti_MaleWare "Install Anti-MaleWare"
Softaculous "Install Softaculous"
ModSec "Install ModSecurity"
OpsView "Add OpsView Agent"
External_Backup "Add This Server To External Backup"
Check_Backup "Check Backup Configration"
menuitem=$(<"${INPUT}")
#Select Option
case $menuitem in
Setup) setup;;
Nginx_Setup) nginx;;
Anti-MaleWare) anti-maleware;;
Softaculous) Softaculous;;
ModSec) modsec;;
OpsView) opsview;;
External_Backup) externalbackup;;
Check_Backup) configbackup;;
Exit) echo "" ; echo "" ; break;;
*) echo "" ; echo "" ; break;;
esac
错误
./main_menu.sh: line 19: : No such file or directory
./main_menu.sh: line 32: break: only meaningful in a `for', `while', or `until' loop
我需要解决此错误,当我按下任何按钮时,请从其他bash脚本进行安装
此致敬意
我在这里找到了答案。有一个疯狂的重定向序列可以交换 stdout 和 stderr,以便菜单可以显示在屏幕上,但答案可以通过命令替换来捕获:
我清理了很多你的代码,使用数组来保存东西。
#!/bin/bash
options=(
--backtitle "Setup Scripts "
--title "[Main Menu]"
--menu "You can use the UP/DOWN arrow keys, Or the number keys 1-9 to choose an option.
Choose the option" 18 70 8
)
choices=(
Setup "Start Setup And Secure this Server"
Nginx_Setup "Install Nginx"
Anti_MaleWare "Install Anti-MaleWare"
Softaculous "Install Softaculous"
ModSec "Install ModSecurity"
OpsView "Add OpsView Agent"
External_Backup "Add This Server To External Backup"
Check_Backup "Check Backup Configration"
)
menuitem=$( dialog "${options[@]}" "${choices[@]}" 3>&1 1>&2 2>&3 3>&- )
case $menuitem in
Setup) setup ;;
Nginx_Setup) nginx ;;
Anti-MaleWare) anti-maleware ;;
Softaculous) Softaculous ;;
ModSec) modsec ;;
OpsView) opsview ;;
External_Backup) externalbackup ;;
Check_Backup) configbackup ;;
"") clear ;;
esac