In Linux, commands can be used to form dialog boxes. The dialog box formed by Linux command line is in the form of code. Whiptail is a command line that Linux can form a dialog box. This article will introduce Linux's method of using whiptail to form a dialog box.
share something of a written.
#! /bin/bash
trap “” 2
while true
do
OPTION=$(whiptail --title “Email Manager” --nocancel --menu “Choose your option& rdquo; 15 60 4 \\
“1” “Add Email User” \\
“2” “Delete Email User”
“3” “List Email User” \\
“4” “EXIT” 3&1 1&2 2&3)
case $OPTION in
1)
EmailAddress=$(whiptail --title “EmailAddress-form Input Box” --inputbox “What is your add EmailAddress?” 10 60 @shenxu.com 3》&1 1&2 2&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
grep $EmailAddress /etc/postfix/virtual_mailbox_maps/dev/nul
exitstatus=$?
if [ $exitstatus = 0 ]; then
whiptail --msgbox “The Email Address is a existed” 10 40
elif (whiptail --title “ Add Yes/No Box” --yesno “Are you sure add $EmailAddress.” 10 60) then
/etc/postfix/mailadd.sh $EmailAddress
whiptail --msgbox <; Email Address $EmailAddress is a added.” 10 40
fi
else
whiptail --msgbox “You chose Cancel.” 10 40< Br>
fi
;;
2)
EmailAddress=$(whiptail --title “EmailAddress-form Input Box” --inputbox “What Is your Delete EmailAddress?” 10 60 @shenxu.com 3》&1 1&2 2&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
grep $EmailAddress /etc/postfix/virtual_mailbox_maps/dev/nul
exitstatus=$?
if [ $exitstatus ! = 0 ]; then
whiptail --msgbox “The Email Address $EmailAddress is a not exist.” 10 40
elif (whiptail --title “Add Yes/No Box&rdquo ; --yesno “Are you sure delete $EmailAddress.” 10 60) then
/etc/postfix/maildel.sh $EmailAddress
whiptail --msgbox “The Email Address $EmailAddress is a deleted.” 10 40
fi
else
whiptail --msgbox “You chose Cancel.” 10 40
Fi
;;
3)
EmailAddress=$(cat /etc/postfix/virtual_mailbox_maps |
Awk ‘{print $1}’)
whiptail --msgbox “The Email User list are $EmailAddress.” --scrolltext 20 40
;;
4)
echo “EXIT”
break
;;
esac
done
trap : 2
whiptail --title “Email Manager” --nocancel --menu “Choose your option" 15 60 4 \\
“1” “Add Email User” \\
“2” “Delete Email User” \\
“3” “List Email User” \\
“4” “EXIT” 3 &1 1&2 2&3
--title “Email Manager” is the title, double quotes are filled out by yourself
--nocancel is in This graphic does not display the cancellation, only the OK
--menu “Choose your option" 15 60 4 is the menu prompt, the double quotes are filled in the prompt information, 15 is high , 60 is the length, 4 is a selection item
The following 1-4 are their own tips
The last comparison is key, 3"&1 1"&2 2"& 3 is to fill the selected content into the variable OPTION
whiptail --title “EmailAddress-form Input Box” --inputbox “What is your add EmailAddress? ” 10 60 @shenxu.com 3》&1 1&2 2&3
--inputbox “What is your add EmailAddress? ” can form a prompt box for user input
@shenxu.com is the default input text value
whiptail --msgbox “You chose Cancel.” 10 40 yes Show a line of your tips
In fact, there is --infobox, it seems to be very similar to msgbox, in fact, it is basically not used, it is something that can be seen when the shell is running.
--scrolltext 20 40 is to scroll up and down when displaying multiple lines
In addition, --passwordbox is input like text, which is displayed as ***
Whiptail --checklist “choose” 15 60 2 “1” “aa” ON “2” “bb” ON
15 60 is still high and wide, 2 is there are several options, and Like the menu, there is an ON or OFF status after the menu, that is, the default is not selected after the menu comes out, On is selected, OFF is not selected, use the space bar to select. Can choose more.
--radiolist, you can't choose more. There can only be one ON, others must be OFF
There is also a --gauge showing the progress bar, which I feel is useless.
#! /bin/bash
{
for n in `seq 100`
do
sleep 1
echo $n
done
} |
Whiptail --gauge “Please wait while installing" 6 60 0
The above is the way Linux uses whiptail to form a dialog box. Copy the written code into the whiptail to form a dialog box.
In Linux system apachectl is a command related to the Apache HTTP server program. The first half of
Linux users in the process of using, sometimes encountered Fatal error, run database recovery and ot
Kid3 can modify the tag tag of ID3 in mp3, can also modify the tag tag of ID3v1 and ID3v2 at the sam
Using Docker on a Linux system can repeatedly deploy software in an environment, which makes it poss
Ubuntu 12.04 installs the method using GNOME 3
How to sniff HTTP traffic under Linux
How to configure XFS file system for Linux system
Ubuntu uses the command to install qBittorrent
How to fix sublime text in Linux to launcher
Linux grub2 startup failure solution
Summary of problems often encountered when using Linux for the first time
How to install and configure Git in Ubuntu system
The Linux find command combined with xargs method
Win7 easily defragmenting disk fragments
Win10 update driver after the splash screen solution
Create personalized Win8, Win8 official version of the beautification graphic tutorial
Win8 Encyclopedia 54: How to close the operation center
How to copy files to OneDrive in Win8.1
Integrated OneDrive and full system backup in Win10 build 9901
Ingeniously set the Windows 7 system back to the "original"
Share two tricks to achieve Windows XP system automatic restart tips