I am trying to create a menu box with Whiptail, taking in the variables from a txt.file called Name.txt which has just 4 names listed for now, one below each other..ie
Dave
John
Mike
Mary
Bash script is below and calls the txt file above
=========================================
#! /bin/bash
saveIFS="$IFS"
IFS=$'\n'
array=($(<Name.txt))
IFS="$saveIFS"
echo ""
for i in "${array[@]}"; do echo "$i"; done # iterate over the array
echo "These are my Varibles above "
echo ""
#This is where the Wiptail script comes in..passing in the array ${array[@]}
whiptail --backtitle "Hi" --title "These are the names" --menu "Please select the name you like" 14 40 6 "${array[@]}"
#This shows exit status
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "User selected Ok and entered "
#This is where I would like to echo out the value selected
#echo value
else
echo "User selected Cancel."
fi
===========================================
I am trying to catch the selection that was selected for the next part of a script but cant seem to do this
Also when I run the Wiptail menu, it shows 2 names on each line. I had been hoping to have it listed one below the other
on return, the selected tag is printed to stderr. Don't know if the triple redirection above will do. In your names file, try to use two field entries like 1 Dave 2 John ... etc.