2016-08-02 57 views
1

是否可以覆蓋whiptailmsgbox的退出狀態?默認情況下,點擊OK按鈕存在whiptail應用程序。理想情況下,我想回去結束我的主菜單頁面上,因爲這是我的應用程序的焦點:從msgbox中覆蓋鞭exit退出狀態

#! /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 

主菜單...

The main menu

選項2菜單...

Option 2 menu

點擊「確定」在這一點完全存在我的應用程序。相反,我希望它退出到主菜單。

回答

1

原來這是比預期的要容易得多,只是包裹在一個while循環:

while true 
do 
    ..... 
done