• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 667
  • Last Modified:

bash script - dialog

I am writing a quite complex (for me) interface using dialog.
I was wondering if anyone can provide a solution for the following situation:
Instead of creating a fix list of items in a menu like this:

dialog --title "bla" --menu "bla2 " 11 60 4 \
   "1" "selection 1" \
   "2" "selection 2" \
   "3" "selection 3 \
   "4" "Exit" 2>/tmp/x

I need a VARIABLE list of items
Of course, the dimension of the dialog box can be automatically resized using 0 0 0 as dimension, however I see no solution to getting menu entries from a loop.

It should look like:
dialog --title "bla" --menu "bla2 " 0 0 0 \
for i in 1 2 3 4 5
 do
   "$i" "selection $i" \
 done
 "E" "Exit" 2>/tmp/x
Since there's no way AFAIK to introduce a for/while loop inside the dialog body, I'm looking for an alternative.

Anyone can give one?
Thank you
0
kronostm
Asked:
kronostm
1 Solution
 
tty2Commented:
#!/bin/bash

echo -n > test.rc
for i in 1 2 3 4 5; do echo \"$i\" \"selection $i\" >> test.rc; done
echo \"E\" \"Exit\" >> test.rc

dialog --title "bla" --menu "bla2 " 11 60 4 --file test.rc
0
 
kronostmAuthor Commented:
Thank you, exactly what I was looking for.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now