在Linux中可以使用命令来形成对话框,Linux命令行形成的对话框就是以代码的形式出现。whiptail就是一个Linux可以形成对话框的命令行,本文就来介绍一下Linux使用whiptail形成对话框的方法。
分享一个写好的东西。
#!/bin/bash
trap “” 2
while true
do
OPTION=$(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)
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 “The Email Address $EmailAddress is a added.” 10 40
fi
else
whiptail --msgbox “You chose Cancel.” 10 40
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” --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 (北联网教程,专业提供视频软件下载)
……