2 # Whiptail is the interactive shell Scrpting
3 OPTION=$(whiptail --title "Whiptail Shell Script Menu" --menu "Choose your option" 15 60 4 \
4 "1" "Change Password" \
5 "2" "Change UserName" \
7 "4" "exit" 3>&1 1>&2 2>&3)
10 if [ $exitstatus = 0 ]; then
11 echo "Your chosen option:" $OPTION
14 1) echo "Option1 Selected"
15 if (whiptail --title "Change Password" --yes-button "Yes" --no-button "No" --yesno "Do you need to changed Password ?" 10 60) then
16 echo "password Selection Yes$?."
19 PASSWORD=$(whiptail --passwordbox "please enter your secret password" 8 78 --title "Change Password" 3>&1 1>&2 2>&3)
20 # A trick to swap stdout and stderr.
21 # Again, you can pack this inside if, but it seems really long for some 80-col terminal users.
23 if [ $exitstatus = 0 ]; then
24 echo "User selected Ok and entered " $PASSWORD
25 touch sample_out_put.txt
26 echo $PASSWORD > sample_out_put.txt
30 for ((i = 0 ; i <= 100 ; i+=5)); do
34 } | whiptail --gauge "Password Updating.." 6 50 0
38 echo "User selected Cancel."
43 echo "Password Selection No$?."
46 2) echo "option2 Selected"
47 # Change User Name Box
48 NAME=$(whiptail --inputbox "Change Username " 8 78 --title "Changed UserName" 3>&1 1>&2 2>&3)
50 if [ $exitstatus = 0 ]; then
51 echo "UserName Changed " $NAME
52 if (whiptail --title "Confirm Change UserName" --yes-button "Yes" --no-button "No" --yesno "Do you need to changed UserName ?" 10 60) then
53 echo "Username Confirm Yes$?."
56 for ((i = 0 ; i <= 100 ; i+=5)); do
60 } | whiptail --gauge "UserName Updating.." 6 50 0
67 echo "UserName Not Changed"
71 3) echo "Option3 Selected"
76 for ((i = 0 ; i <= 100 ; i+=5)); do
80 } | whiptail --gauge "exit..." 6 50 0
84 echo "You chose Cancel."