#!/bin/bash if(whiptail --title "Test Yes/No Box" --yesno "Choose between Yes and No."1060) then echo "You chose Yes. Exit status was $?." else echo "You chose No. Exit status was $?." fi
或者,你可以是“–yes-button” ,”–no-button”选项。
1 2 3 4 5 6
#!/bin/bash if(whiptail --title "Test Yes/No Box" --yes-button "Skittles" --no-button "M&M's" --yesno "Which do you like better?"1060) then echo "You chose Skittles Exit status was $?." else echo "You chose M&M's. Exit status was $?." fi
#!/bin/bash PET=$(whiptail --title "Test Free-form Input Box" --inputbox "What is your pet's name?"1060 Wigglebutt 3>&11>&22>&3) exitstatus=$? if [ $exitstatus = 0 ]; then echo "Your pet name is:" $PET else echo "You chose Cancel." fi
#!/bin/bash PASSWORD=$(whiptail --title "Test Password Box" --passwordbox "Enter your password and choose Ok to continue."10603>&11>&22>&3) exitstatus=$? if [ $exitstatus = 0 ]; then echo "Your password is:" $PASSWORD else echo "You chose Cancel." fi
#!/bin/bash DISTROS=$(whiptail --title "Test Checklist Dialog" --radiolist \ "What is the Linux distro of your choice?"15604 \ "debian""Venerable Debian" ON \ "ubuntu""Popular Ubuntu" OFF \ "centos""Stable CentOS" OFF \ "mint""Rising Star Mint" OFF 3>&11>&22>&3) exitstatus=$? if [ $exitstatus = 0 ]; then echo "The chosen distro is:" $DISTROS else echo "You chose Cancel." fi