Reputation: 848
I am working on following linux dialog box. I am not able to understand it's behavior. This works correctly i.e. correctly displays three checkboxes.
#!/bin/sh
dialog --backtitle "Test" \
--title "Checkbox test " \
--checklist "Choose from following" 0 0 0 \
apple "The apple is green" on \
mango "The mango is golden" on \
pappaya "The pappaya is brown" on \
2> /tmp/optional.out
OPTIONAL=`cat /tmp/optional.out | \
sed -e "s/\"//g" -e "s/ /|/g" -e "s/|$//"`
echo 'optional :'$OPTIONAL
After execution i get following output as.
optional :apple|mango|pappaya
However I want to show the user only two options. So I made the following changes.
#!/bin/sh
dialog --backtitle "Test" \
--title "Checkbox test " \
--checklist "Choose from following" 0 0 0 \
apple "The apple is green" on \
mango "The mango is golden" on \
#pappaya "The pappaya is brown" on \
2> /tmp/optional.out
OPTIONAL=`cat /tmp/optional.out | \
sed -e "s/\"//g" -e "s/ /|/g" -e "s/|$//"`
echo 'optional :'$OPTIONAL
But after doing this I get no output i.e. optional :
. Why is that? How can I make it work.
Upvotes: 0
Views: 1041
Reputation: 8395
I'm now thinking you did comment and broke your line. (it happens many times to me)
You may try this:
#!/bin/sh
dialog --backtitle "Test" \
--title "Checkbox test " \
--checklist "Choose from following" 0 0 0 \
apple "The apple is green" on \
mango "The mango is golden" on \
2> /var/tmp/optional.out
OPTIONAL=`cat /var/tmp/optional.out | \
sed -e "s/\"//g" -e "s/ /|/g" -e "s/|$//"`
echo 'optional :'$OPTIONAL
Upvotes: 1