任何人都可以帮助我解决这个问题。
我的狂欢是
#!/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脚本中执行此操作来安装
诚挚的问候,
发布于 2014-02-20 22:16:25
我找到了一个答案,这里。有一个疯狂的重定向序列,可以交换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 ;;
esachttps://stackoverflow.com/questions/21918293
复制相似问题