歡迎您光臨本站 註冊首頁

Dialog--一段小Shell

←手機掃碼閱讀     火星人 @ 2014-03-23 , reply:0

來源:http://www.ubuntuchina.com
作者:casual0402


距離寫這篇文章已經有段時間了,那時候是在PHPChina的水區遊盪,閑來無事就弄了這麼一段。分享一下。望不吝賜教。
QUOTE:
#!/bin/sh

dialog --title "夜色調查" --msgbox "歡迎來到夜色" 9 18 #彈出一個消息框,標題 內容 高度 寬度

dialog --title "確認框" --yesno "你想參加調查嗎?" 9 18 #彈出一個選擇框yes or no 高度 寬度
if [ $? != 0 ]; then #選擇了yes的返回碼是0
dialog --infobox "仍然感謝" 5 20 #彈出一個信息框 內容 高度 寬度
sleep 2
dialog --clear
exit 0
fi

dialog --title "調查" --inputbox "請輸入你的用戶名" 9 30 2>_1.txt #彈出一個輸入框,重定向標準錯誤流(2)到臨時文件_1.txt
Q_name=$(cat _1.txt) #將內容放到變數 Q_name中

dialog --menu "$Q_name,你有馬甲嗎?" 7 10 2 1 "有" 2 "沒有" 2>_1.txt #這個就不解釋了
Q_answer=$(cat _1.txt)

if [ "$Q_answer" = "1" ];then
dialog --msgbox "好樣的!" 12 25
fi

sleep 5
dialog --clear

exit 0


[火星人 ] Dialog--一段小Shell已經有567次圍觀

http://coctec.com/docs/linux/show-post-109856.html