1

是否可以从whiptail msgbox覆盖退出状态?默认情况下,点击 OK 按钮存在whiptail 应用程序。理想情况下,我想最终回到我的主菜单页面,因为这是我的应用程序的焦点:

#! /bin/bash

OPTION=$(whiptail --title "Configuration Menu" --menu "Choose an option" 40 78 30 \ "1"     "Return to main menu." \ "2"     "Show current configuration." \ "3"     "Enter Neo Serial Number." \ "4"     "Change Neo IP Address." \ "5"     "Change Neo Gateway."  3>&1 1>&2 2>&3)

exitstatus=$?

case "$OPTION" in   2)
    whiptail  --title "Current Configuration" --msgbox "Your current Neo configuration \n
        IP Address:  `ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` \n
        Gateway: `ip route | awk '/default/ { print $3 }'` \n
        DNS Server(s): `ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | g$
    ;; esac

主菜单...

主菜单

选项 2 菜单...

选项 2 菜单

此时点击“确定”完全存在我的应用程序。相反,我希望它退出到主菜单。

4

1 回答 1

1

事实证明它比预期的要容易得多,只是包裹在一个 while 循环中:

 while true
 do
  .....
 done
于 2016-08-02T17:37:51.943 回答