Hi again
This is just a sample whiptail menu.
Works great, but have been trying to get the chosen value into a variable but failing pretty bad...its ther but unsure how to echo it out when needed
#! /bin/bash
#This is the menu
whiptail --title "Menu example" --menu "Choose an option" 20 78 16 \
"<-- Back" "Return to the main menu." \
"Add User" "Add a user to the system." \
"Modify User" "Modify an existing user." \
"List Users" "List all users on the system." \
"Add Group" "Add a user group to the system." \
"Modify Group" "Modify a group and its list of members." \
"List Groups" "List all groups on the system."
#want to grab the result here and place in a varible called 'choice' and just echo it out if possible
#This shows exit status
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "User selected Ok"
echo "User eneterd $choice"
else
echo "User selected Cancel."
fi
Any ideas would be great..thanks again
---------- Post updated at 08:29 AM ---------- Previous update was at 06:12 AM ----------
Been messing more and able to get it going a bit
and mofifies it to something like this
The only thing is, I get my results OK...but the if, then choice does not do as expected
Below is a example
#! /bin/bash
#
WM=$(whiptail --backtitle "Hi" --title "These are the names" --radiolist "Please select what is is to be turned on or off" 30 60 20 "ON" "Power on " ON "OFF" "Power OFF " OFF 3>&1 1>&2 2>&3)
echo "User selected Ok and entered $WM"
S1='ON'
S2='OFF'
if [ $S1==$WM ];
then
echo "You pressed ON('$WM')"
else
echo "You Pressed OFF('$WM')"
fi
What ever I press, I get the You pressed ON option