参数详解:
dialog --clear
整个萤幕会清除後离开
dialog --create-rc file
dialog支援动态规划,这个功能会产生一个样本。
--title title
对话盒上的标题文字
--backtitle backtitle
桌面背景的标题
box-options
dialog目前提供了yes/no box, menu box, input box, message box, text box, info box, checklist box, radiolist box, 及gauge box共九种widget.
Exit Status
如果按下Yes或OK按键.则会返回0.No或Cancel会返回1.如果按下ESC或发生错误.则会返回-1
--yesno text height width
# dialog --title "hello" --backtitle "Dialog" --yesno "Is everything okay" 20 60
--msgbox text height width
# dialog --title "hello" --backtitle "Dialog" --msgbox "Is everything okay" 20 60
--infobox text height width
# dialog --title "hello" --backtitle "Dialog" --infobox "Is everything okay?" 10 60
Infobox会在显示讯息後立即离开,在console的状况下,讯息会留下,但在X Terminal下,由於X Terminal会立即将讯息清除,Screen Shot抓不到,因此这里没有ScreenShot。您可以在console下测试。
--inputbox text height width [init]
# dialog --title "hello" --backtitle "Dialog" --inputbox "Is okay?" 10 60 "yes"
--textbox file height width
[foxman@foxman copyright]# dialog --title "Array 30" --backtitle "All " --textbox file 20 75
textbox很像是个简单的text viewer,它会显示档案中的文字。
--menu text height width menu-height [ tag item ] ...
# dialog --title "Menu Example" --menu "MENU" 20 60 4 tag1 " item1" tag2 "item2" tag3 "item3" tag4 "item4"
--checklist text height width list-height [ tag item status ] ...
# dialog --title "CheckList Example" --checklist "Check List" 20 60 4 tag1 "item1" on tag2 "item2" off tag3 "item3" on tag4 "item4" off
--radiolist text height width list-height [ tag item status ] ...
# dialog --title "RadioList Example" --radiolist "Radio List" 20 60 4 tag1 "item1" on tag2 "item2" off tag3 "item3" on tag4 "item4" off
--gauge text height width percent
# dialog --title "Installation" --backtitle "Star Linux" --gauge "Linux Kernel" 10 60 50
gauge widget在启动後,会从stdin读取percent进来,读到EOF时结束。
范例:
yesno
if dialog --title "title" --backtitle "backtitle"
--yesno "Are you ready to rumble?" 5 60; then
echo "Yeahhhhh"
else
echo "Nap..."
fi
inputbox
if dialog --title "The future is here"
--inputbox "Where do you want to go tomorrow?"
10 75 "Penguin" 2>my_own_destiny;then
way=`cat my_own_destiny`
echo "My way is $way"
else
echo "freak out"
fi
menu
if dialog --title "title" --menu "MENU" 20 60 14
tag1 "item1" tag2 "item2" 2>select ;then
selection=`cat select`
echo "my selection is $selection"
else
echo "go"
fi
checklist
if dialog --title "title" --checklist "checklist"
20 60 14 tag1 "item1" on tag2 "item2" off 2>select ;then
selections=`cat select`
echo "My selections are:"
for i in $selections ; do
echo $i
done
else
echo "go"
fi
radiolist
if dialog --title "title" --radiolist "checklist"
20 60 14 tag1 "item1" on tag2 "item2" off 2>select;then
selection=`cat select`
echo "My selection is $selection"
else
echo "go"
fi