Alex Schuster wrote:
Andrew writes:


Do you need the /tmp/dlgmenu file at all?


Yes. The menu is built dynamically. /tmp/dlgmenu could contain:


hda "Auto-partition drive /dev/hda" sda "Auto-partition drive /dev/sda"
...


Okay, but if you generate the file just to read it out later in the same script, a variable might do also. If not, you could do it like this: get the number of lines in the file, read each line, and add it to an array of arguments:

menufile=/tmp/dlgmenu
n=$(( `cat $menufile | wc -l` ))
for (( i=0; i < n; i++ ))
do
        line[$(( $i ))]=`cat $menufile | head -$(( $i+1 )) | tail -1`
done

dialog --menu "Choose a partition..." 12 60 8 "[EMAIL PROTECTED]" 2> > /tmp/menuoption

There might be more elegant way, though.

I found out what the problem was. The above would still have the same problem, I believe. bash was interpreting the whole thing as 1 argument. Someone suggested to me to do:


DLGCMD="dialog --menu "Choose..." 12 60 8 `cat /tmp/dlgmenu` 2> /tmp/menuoption
echo $DLGCMD | bash

This worked just fine.

--
Andrew Gaffney


-- [EMAIL PROTECTED] mailing list



Reply via email to