Dialog Box using Whiptail
Create Message Box
|
Code For Message Box
|
|
whiptail –title “Message” –msgbox “Are you having fun ?” 10 50
|
Create an Input Box
|
Code For Input Box
|
|
X=$(whiptail –title “Feedback Form” –inputbox “How was the food that you ordered ?” 10 50 Excellent 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]
then
echo “Thank You” $X
else
echo “You cancelled the form”
fi
|
Create a Password Box
|
Code For Password Box
|
|
X=$(whiptail –title “Private Work” –passwordbox “Enter You password” 10 50 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]
then
whiptail –title “Private work” –msgbox “Your password is $X” 10 50
else
whiptail –title “Private Work” –msgbox “See you soon” 10 50
fi
|
Create a Guage Bar or Progress Bar
|
Code For Progress Bar
|
|
{
for ((i=0; i<=100; i++ ))
do
sleep 1
echo $i
done
} | whiptail –gauge “Installing Grand Theft Auto V” 6 60 0
|
Create a CheckList
|
Code For Checklist
|
|
O=$(whiptail –title “Checklist” –checklist “Choose from these” 15 60 4 \
“1” “GTA 4” ON \
“2” “GTA 5” ON \
“3” “Just Cause 2” OFF \
“4” “MineCraft” OFF 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]
then
whiptail –title “Message” –msgbox “You Selected $O” 10 50
whiptail –title “Thankyou” –msgbox “Thank You” 10 50
else
whiptail –title “Thankyou” –msgbox “See You soon” 10 50
fi
|
Create a Menu Box
|
Code For Menu
|
|
O=$(whiptail –title “Choose any one” –menu “Choose from these” 15 60 4 \
“1” “GTA 4v” \
“2” “GTA 5” \
“3” “Just Cause 2” \
“4” “MineCraft” 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]
then
whiptail –title “Menu” –msgbox “You Selected $O” 10 50
whiptail –title “Thankyou” –msgbox “Thank You” 10 50
else
whiptail –title “Thankyou” –msgbox “See You soon” 10 50
fi
|
Create YesNo Box
|
Code For YesNo Box
|
|
whiptail –title “YesNo” –yesno “Are you having fun ?” 10 50
|
Change button text
if (whiptail –title “Welcome” –yesno “Welcome\n Whether you want Veg food or Non Veg Food ?” –yes-button “Veg” –no-button “Non-Veg” 10 60)then
while :
do
X=$(whiptail –title “Vegetarian Food List” –checklist “Select the food items you want” 30 60 5 \
“Matar Paneer” “1” OFF \
“Paneer Butter Masala” “2” OFF \
“Shaahi Paneer” “3” OFF \
“Dal Makhni” “4” OFF \
“Bhindi Fry” “5” OFF 3>&1 1>&2 2>&3)
if ( -z “$X” )then
continue
else
break
fi
done
if (whiptail –title “Your Order” –yesno “You selected $X \n Click to confiirm” –yes-button “Confirm” 10 60)then
{
for ((i=0;i<=100;i++))
do
sleep 0
echo $i
done
} | whiptail –gauge “Booking Your Order” 6 60 0
whiptail –title “Thankyou” –msgbox “Your Items have been booked !!” 10 60
else
whiptail –title “Thankyou” –msgbox “Thankyou for wasting our time you moron” 20 60
fi
else
Y=$(whiptail –title “Non-Vegetarian Food List” –checklist “Select the food items you want” 30 60 5 \
“Chicken Fry” “1” OFF \
“Mutton Gravy” “2” OFF \
“Chicken Boneless” “3” OFF \
“Chicken Alive” “4” OFF \
“Grind Chicken” “5” OFF 3>&1 1>&2 2>&3)
if (whiptail –title “You Order” –yesno “You selected $Y \n Click to confirm” –yes-button “Confirm” 10 60)then
{
for ((i=0;i<=100;i++))
do
sleep 0
echo $i
done
} | whiptail –gauge “Booking Your Order” 6 60 0
whiptail –title “Thankyou” –msgbox “You items have been booked !!” 10 60
else
whiptail –title “Thankyou” –msgbox “Thnkyou for wasting our time you moron” 20 60
fi
fi
Here is the output






