I want to use whiptail
to generate a checkbox list based on the output from another program. Only the first word on each line of the output from the first program is necessary, so I extract it using awk
.
To learn about how bash handles arrays, I have been using this link by tldp. I got how to check the size of arrays from here.
This doesn't run as expected, but if I copy the echo
output, and type "whiptail
" in front of it, it does work.
How do I fix this code so that it works?
example program.sh
:
#! /bin/bash
find ./ -printf "%f\n"
example mainscript.sh
:
#! /bin/bash
MYARRAY=($(./program.sh -l | awk '{print $1;}'))
MYPARAMS=" --checklist \"\" 15 40 5"
i=0
while [[ $i -lt ${#MYARRAY[@]} ]]
do
MYPARAMS+=" \"${MYARRAY[$i]}\" \" \" off"
i=$[$i+1]
done
whiptail $MYPARAMS
echo $MYPARAMS
exit
Aucun commentaire:
Enregistrer un commentaire