I cannot seem to get the dialog box to give me multiple select options.
Here's a simplified version of what I'm trying to accomplish in a dialog box:
Menu Selection
"Pick one or more options:"
1) Option 1
2) Option 2
3) Option 3
<select> <exit>
Where the user sees this when selecting:
"Pick one or more options:"
* 1) Option 1
* 2) Option 2
3) Option 3
<select> <exit>
And upon enter key on select sees: "You've selected Options 1 and 2".
Here is what I have so far:
#!/bin/bash
#initialize
MENU_OPTIONS=
COUNT=0
IFS=$'\n'
#get menu options populated from file
for i in `cat my_input_file.log`
do
COUNT=$[COUNT+1]
MENU_OPTIONS="${MENU_OPTIONS} $i ${COUNT} off "
done
#build dialogue box with menu options
cmd=(dialog --backtitle "Menu Selection" --checklist "Pick 1 or more options" 22 30 16)
options=(${MENU_OPTIONS})
choices=$("${cmd[@]}" "${options[@]}" 2>&1 1>/dev/tty)
#do something with the choices
for choice in $choices
do
echo $choice selected
done
When running this (./menu.bash) on the CLI I receive the following:
Error: Expected at least 7 tokens for --checklist, have 5. selected
Use --help to list options. selected
What am I missing?