zenity doesn't display all list with variables











up vote
2
down vote

favorite
1












I am making a search and install PPA script for Ubuntu. This script with zenity works 80%, the problem is when this script searches; displays only the first line. I need all lines



#!/bin/sh

# simple search and install PPA
# by David Vásquez


if [ $# -gt 0 ] ; then
echo "$*"
else
echo "No input"
exit
fi

code=$*

cat /dev/null > /tmp/ppa
cat /dev/null > /tmp/ppa-url-tmp


mojito=$(curl https://launchpad.net/ubuntu/+ppas?name_filter=$code | grep -e '+archive/' | grep "$code" | awk -F'<td><a href="/~' '{print $2}' | awk -F'">' '{print $1}' | uniq | tr -d '~')

echo $mojito | tr ' ' 'n' | tee -a /tmp/ppa-url-tmp




file="/tmp/ppa-url-tmp"
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' | awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' | awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' | awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )


echo $title $description $support $line | uniq -u | tee -a /tmp/ppa

zenity --list --radiolist --title="Package installation." --text="Select package to be installed" --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "in" "$title" "$description" "$support" "$line"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi

done <"$file"


My other attempt here (same results)



From terminal a example



myscript pipelight


enter image description here










share|improve this question
























  • @slm if you test: myscript pipeligth s28.postimg.org/47gop2p25/ppaserch.png
    – davidva
    May 31 '14 at 9:27










  • For all also You can see all lines in /tmp/ppa ;)
    – davidva
    May 31 '14 at 9:48










  • @slm I had the same result if I change zenity out the while loop :/
    – davidva
    May 31 '14 at 9:53










  • @slm I need the entire list. In my 3 test dl.dropboxusercontent.com/u/76388877/ppa-installerf-zenity3 I had the same result :/
    – davidva
    May 31 '14 at 10:06










  • @slm exactly! How did you do? What is wrong with my code?
    – davidva
    May 31 '14 at 16:52















up vote
2
down vote

favorite
1












I am making a search and install PPA script for Ubuntu. This script with zenity works 80%, the problem is when this script searches; displays only the first line. I need all lines



#!/bin/sh

# simple search and install PPA
# by David Vásquez


if [ $# -gt 0 ] ; then
echo "$*"
else
echo "No input"
exit
fi

code=$*

cat /dev/null > /tmp/ppa
cat /dev/null > /tmp/ppa-url-tmp


mojito=$(curl https://launchpad.net/ubuntu/+ppas?name_filter=$code | grep -e '+archive/' | grep "$code" | awk -F'<td><a href="/~' '{print $2}' | awk -F'">' '{print $1}' | uniq | tr -d '~')

echo $mojito | tr ' ' 'n' | tee -a /tmp/ppa-url-tmp




file="/tmp/ppa-url-tmp"
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' | awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' | awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' | awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )


echo $title $description $support $line | uniq -u | tee -a /tmp/ppa

zenity --list --radiolist --title="Package installation." --text="Select package to be installed" --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "in" "$title" "$description" "$support" "$line"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi

done <"$file"


My other attempt here (same results)



From terminal a example



myscript pipelight


enter image description here










share|improve this question
























  • @slm if you test: myscript pipeligth s28.postimg.org/47gop2p25/ppaserch.png
    – davidva
    May 31 '14 at 9:27










  • For all also You can see all lines in /tmp/ppa ;)
    – davidva
    May 31 '14 at 9:48










  • @slm I had the same result if I change zenity out the while loop :/
    – davidva
    May 31 '14 at 9:53










  • @slm I need the entire list. In my 3 test dl.dropboxusercontent.com/u/76388877/ppa-installerf-zenity3 I had the same result :/
    – davidva
    May 31 '14 at 10:06










  • @slm exactly! How did you do? What is wrong with my code?
    – davidva
    May 31 '14 at 16:52













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I am making a search and install PPA script for Ubuntu. This script with zenity works 80%, the problem is when this script searches; displays only the first line. I need all lines



#!/bin/sh

# simple search and install PPA
# by David Vásquez


if [ $# -gt 0 ] ; then
echo "$*"
else
echo "No input"
exit
fi

code=$*

cat /dev/null > /tmp/ppa
cat /dev/null > /tmp/ppa-url-tmp


mojito=$(curl https://launchpad.net/ubuntu/+ppas?name_filter=$code | grep -e '+archive/' | grep "$code" | awk -F'<td><a href="/~' '{print $2}' | awk -F'">' '{print $1}' | uniq | tr -d '~')

echo $mojito | tr ' ' 'n' | tee -a /tmp/ppa-url-tmp




file="/tmp/ppa-url-tmp"
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' | awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' | awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' | awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )


echo $title $description $support $line | uniq -u | tee -a /tmp/ppa

zenity --list --radiolist --title="Package installation." --text="Select package to be installed" --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "in" "$title" "$description" "$support" "$line"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi

done <"$file"


My other attempt here (same results)



From terminal a example



myscript pipelight


enter image description here










share|improve this question















I am making a search and install PPA script for Ubuntu. This script with zenity works 80%, the problem is when this script searches; displays only the first line. I need all lines



#!/bin/sh

# simple search and install PPA
# by David Vásquez


if [ $# -gt 0 ] ; then
echo "$*"
else
echo "No input"
exit
fi

code=$*

cat /dev/null > /tmp/ppa
cat /dev/null > /tmp/ppa-url-tmp


mojito=$(curl https://launchpad.net/ubuntu/+ppas?name_filter=$code | grep -e '+archive/' | grep "$code" | awk -F'<td><a href="/~' '{print $2}' | awk -F'">' '{print $1}' | uniq | tr -d '~')

echo $mojito | tr ' ' 'n' | tee -a /tmp/ppa-url-tmp




file="/tmp/ppa-url-tmp"
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' | awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' | awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' | awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )


echo $title $description $support $line | uniq -u | tee -a /tmp/ppa

zenity --list --radiolist --title="Package installation." --text="Select package to be installed" --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "in" "$title" "$description" "$support" "$line"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi

done <"$file"


My other attempt here (same results)



From terminal a example



myscript pipelight


enter image description here







zenity






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Rui F Ribeiro

38.2k1475123




38.2k1475123










asked May 31 '14 at 9:03









davidva

951212




951212












  • @slm if you test: myscript pipeligth s28.postimg.org/47gop2p25/ppaserch.png
    – davidva
    May 31 '14 at 9:27










  • For all also You can see all lines in /tmp/ppa ;)
    – davidva
    May 31 '14 at 9:48










  • @slm I had the same result if I change zenity out the while loop :/
    – davidva
    May 31 '14 at 9:53










  • @slm I need the entire list. In my 3 test dl.dropboxusercontent.com/u/76388877/ppa-installerf-zenity3 I had the same result :/
    – davidva
    May 31 '14 at 10:06










  • @slm exactly! How did you do? What is wrong with my code?
    – davidva
    May 31 '14 at 16:52


















  • @slm if you test: myscript pipeligth s28.postimg.org/47gop2p25/ppaserch.png
    – davidva
    May 31 '14 at 9:27










  • For all also You can see all lines in /tmp/ppa ;)
    – davidva
    May 31 '14 at 9:48










  • @slm I had the same result if I change zenity out the while loop :/
    – davidva
    May 31 '14 at 9:53










  • @slm I need the entire list. In my 3 test dl.dropboxusercontent.com/u/76388877/ppa-installerf-zenity3 I had the same result :/
    – davidva
    May 31 '14 at 10:06










  • @slm exactly! How did you do? What is wrong with my code?
    – davidva
    May 31 '14 at 16:52
















@slm if you test: myscript pipeligth s28.postimg.org/47gop2p25/ppaserch.png
– davidva
May 31 '14 at 9:27




@slm if you test: myscript pipeligth s28.postimg.org/47gop2p25/ppaserch.png
– davidva
May 31 '14 at 9:27












For all also You can see all lines in /tmp/ppa ;)
– davidva
May 31 '14 at 9:48




For all also You can see all lines in /tmp/ppa ;)
– davidva
May 31 '14 at 9:48












@slm I had the same result if I change zenity out the while loop :/
– davidva
May 31 '14 at 9:53




@slm I had the same result if I change zenity out the while loop :/
– davidva
May 31 '14 at 9:53












@slm I need the entire list. In my 3 test dl.dropboxusercontent.com/u/76388877/ppa-installerf-zenity3 I had the same result :/
– davidva
May 31 '14 at 10:06




@slm I need the entire list. In my 3 test dl.dropboxusercontent.com/u/76388877/ppa-installerf-zenity3 I had the same result :/
– davidva
May 31 '14 at 10:06












@slm exactly! How did you do? What is wrong with my code?
– davidva
May 31 '14 at 16:52




@slm exactly! How did you do? What is wrong with my code?
– davidva
May 31 '14 at 16:52










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










From your description and code it sounds like you're looking for something like this:



    ss #1



To get a dialog that's constructed like this your original script needed to be augmented in a few key ways. For starters you need to move the call to construct the zenity dialog so that it's outside your while loop that's collecting all the data about the various PPAs.



The other thing lacking was a data structure to store all the bits about the PPAs that you were collecting. For this a Bash array makes the perfect "container" for this data.



lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")


This will continue to append the results that you collect via the while loop to an array called lines. This array is then given to zenity, it contains the column data.



Complete script



Here's the whole thing put together, which produced the above screenshot of the dialog.



#!/bin/bash

file="ppa-url-tmp"

lines=()
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' |
awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' |
awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' |
awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )

echo $title $description $support $line | uniq -u | tee -a /tmp/ppa
lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")

done <"$file"

zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi


Additional debugging tip



When you're unclear what something is doing in a Bash script reach for the commands set -x and set +x. These will enable and disable Bash's verbosity which can really help shed light on what's going on. Here's my zenity command with just verbosity turned up for it:



set -x
zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"
set +x


And here's what it looks like when I run ./myscript ...:



+ zenity --list --radiolist '--title=Package installation.' '--text=Select package to be installed' --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA FALSE '"pipelight-daily : Michael Müller"' '"This PPA provides daily builds of the Pipelight project pipelight-daily "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight-daily FALSE '"Pipelight : Michael Müller"' '"Pipelight allows one to run Silverlight inside a Linux browser using Wine Pipelight "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight FALSE '"pipelight-experimental : “Pipelight Dev Team” team"' '"Experimental packages for Pipelight  pipelight-experimental "' '"14.04 13.10 13.04"' pipelight/+archive/experimental FALSE '"pipelight-daily : “Pipelight Dev Team” team"' '"pipelight-daily "' '"14.10 14.04 13.10"' pipelight/+archive/daily FALSE '"pipelight-stable : “Pipelight Dev Team” team"' '"pipelight-stable "' '"14.10 14.04 13.10"' pipelight/+archive/stable FALSE '"libva : “Pipelight Dev Team” team"' '"libva "' '"13.10 12.10 12.04"' pipelight/+archive/libva
+ set +x


The above reveals how all the column components are expanded, properly quoted, by the use of "${lines[@]}".






share|improve this answer





















  • Thanks my friend! it worked, thanks for explain. This script going to help to much people.
    – davidva
    Jun 1 '14 at 8:27






  • 1




    @davidva - glad to have been of help and thanks for the interesting Q. Good luck!
    – slm
    Jun 1 '14 at 12:19










  • I attempted in Xubuntu doesn't read 'lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")" . This is the output: 'Syntax error: "(" unexpected (expecting "done").' I do not understand. But in Fedora, Arch Linux works :/
    – davidva
    Jun 2 '14 at 4:56












  • Solved! only change the first line #!/bin/sh to #!/bin/bash
    – davidva
    Jun 2 '14 at 5:30











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f132826%2fzenity-doesnt-display-all-list-with-variables%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










From your description and code it sounds like you're looking for something like this:



    ss #1



To get a dialog that's constructed like this your original script needed to be augmented in a few key ways. For starters you need to move the call to construct the zenity dialog so that it's outside your while loop that's collecting all the data about the various PPAs.



The other thing lacking was a data structure to store all the bits about the PPAs that you were collecting. For this a Bash array makes the perfect "container" for this data.



lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")


This will continue to append the results that you collect via the while loop to an array called lines. This array is then given to zenity, it contains the column data.



Complete script



Here's the whole thing put together, which produced the above screenshot of the dialog.



#!/bin/bash

file="ppa-url-tmp"

lines=()
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' |
awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' |
awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' |
awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )

echo $title $description $support $line | uniq -u | tee -a /tmp/ppa
lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")

done <"$file"

zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi


Additional debugging tip



When you're unclear what something is doing in a Bash script reach for the commands set -x and set +x. These will enable and disable Bash's verbosity which can really help shed light on what's going on. Here's my zenity command with just verbosity turned up for it:



set -x
zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"
set +x


And here's what it looks like when I run ./myscript ...:



+ zenity --list --radiolist '--title=Package installation.' '--text=Select package to be installed' --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA FALSE '"pipelight-daily : Michael Müller"' '"This PPA provides daily builds of the Pipelight project pipelight-daily "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight-daily FALSE '"Pipelight : Michael Müller"' '"Pipelight allows one to run Silverlight inside a Linux browser using Wine Pipelight "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight FALSE '"pipelight-experimental : “Pipelight Dev Team” team"' '"Experimental packages for Pipelight  pipelight-experimental "' '"14.04 13.10 13.04"' pipelight/+archive/experimental FALSE '"pipelight-daily : “Pipelight Dev Team” team"' '"pipelight-daily "' '"14.10 14.04 13.10"' pipelight/+archive/daily FALSE '"pipelight-stable : “Pipelight Dev Team” team"' '"pipelight-stable "' '"14.10 14.04 13.10"' pipelight/+archive/stable FALSE '"libva : “Pipelight Dev Team” team"' '"libva "' '"13.10 12.10 12.04"' pipelight/+archive/libva
+ set +x


The above reveals how all the column components are expanded, properly quoted, by the use of "${lines[@]}".






share|improve this answer





















  • Thanks my friend! it worked, thanks for explain. This script going to help to much people.
    – davidva
    Jun 1 '14 at 8:27






  • 1




    @davidva - glad to have been of help and thanks for the interesting Q. Good luck!
    – slm
    Jun 1 '14 at 12:19










  • I attempted in Xubuntu doesn't read 'lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")" . This is the output: 'Syntax error: "(" unexpected (expecting "done").' I do not understand. But in Fedora, Arch Linux works :/
    – davidva
    Jun 2 '14 at 4:56












  • Solved! only change the first line #!/bin/sh to #!/bin/bash
    – davidva
    Jun 2 '14 at 5:30















up vote
1
down vote



accepted










From your description and code it sounds like you're looking for something like this:



    ss #1



To get a dialog that's constructed like this your original script needed to be augmented in a few key ways. For starters you need to move the call to construct the zenity dialog so that it's outside your while loop that's collecting all the data about the various PPAs.



The other thing lacking was a data structure to store all the bits about the PPAs that you were collecting. For this a Bash array makes the perfect "container" for this data.



lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")


This will continue to append the results that you collect via the while loop to an array called lines. This array is then given to zenity, it contains the column data.



Complete script



Here's the whole thing put together, which produced the above screenshot of the dialog.



#!/bin/bash

file="ppa-url-tmp"

lines=()
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' |
awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' |
awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' |
awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )

echo $title $description $support $line | uniq -u | tee -a /tmp/ppa
lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")

done <"$file"

zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi


Additional debugging tip



When you're unclear what something is doing in a Bash script reach for the commands set -x and set +x. These will enable and disable Bash's verbosity which can really help shed light on what's going on. Here's my zenity command with just verbosity turned up for it:



set -x
zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"
set +x


And here's what it looks like when I run ./myscript ...:



+ zenity --list --radiolist '--title=Package installation.' '--text=Select package to be installed' --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA FALSE '"pipelight-daily : Michael Müller"' '"This PPA provides daily builds of the Pipelight project pipelight-daily "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight-daily FALSE '"Pipelight : Michael Müller"' '"Pipelight allows one to run Silverlight inside a Linux browser using Wine Pipelight "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight FALSE '"pipelight-experimental : “Pipelight Dev Team” team"' '"Experimental packages for Pipelight  pipelight-experimental "' '"14.04 13.10 13.04"' pipelight/+archive/experimental FALSE '"pipelight-daily : “Pipelight Dev Team” team"' '"pipelight-daily "' '"14.10 14.04 13.10"' pipelight/+archive/daily FALSE '"pipelight-stable : “Pipelight Dev Team” team"' '"pipelight-stable "' '"14.10 14.04 13.10"' pipelight/+archive/stable FALSE '"libva : “Pipelight Dev Team” team"' '"libva "' '"13.10 12.10 12.04"' pipelight/+archive/libva
+ set +x


The above reveals how all the column components are expanded, properly quoted, by the use of "${lines[@]}".






share|improve this answer





















  • Thanks my friend! it worked, thanks for explain. This script going to help to much people.
    – davidva
    Jun 1 '14 at 8:27






  • 1




    @davidva - glad to have been of help and thanks for the interesting Q. Good luck!
    – slm
    Jun 1 '14 at 12:19










  • I attempted in Xubuntu doesn't read 'lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")" . This is the output: 'Syntax error: "(" unexpected (expecting "done").' I do not understand. But in Fedora, Arch Linux works :/
    – davidva
    Jun 2 '14 at 4:56












  • Solved! only change the first line #!/bin/sh to #!/bin/bash
    – davidva
    Jun 2 '14 at 5:30













up vote
1
down vote



accepted







up vote
1
down vote



accepted






From your description and code it sounds like you're looking for something like this:



    ss #1



To get a dialog that's constructed like this your original script needed to be augmented in a few key ways. For starters you need to move the call to construct the zenity dialog so that it's outside your while loop that's collecting all the data about the various PPAs.



The other thing lacking was a data structure to store all the bits about the PPAs that you were collecting. For this a Bash array makes the perfect "container" for this data.



lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")


This will continue to append the results that you collect via the while loop to an array called lines. This array is then given to zenity, it contains the column data.



Complete script



Here's the whole thing put together, which produced the above screenshot of the dialog.



#!/bin/bash

file="ppa-url-tmp"

lines=()
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' |
awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' |
awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' |
awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )

echo $title $description $support $line | uniq -u | tee -a /tmp/ppa
lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")

done <"$file"

zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi


Additional debugging tip



When you're unclear what something is doing in a Bash script reach for the commands set -x and set +x. These will enable and disable Bash's verbosity which can really help shed light on what's going on. Here's my zenity command with just verbosity turned up for it:



set -x
zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"
set +x


And here's what it looks like when I run ./myscript ...:



+ zenity --list --radiolist '--title=Package installation.' '--text=Select package to be installed' --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA FALSE '"pipelight-daily : Michael Müller"' '"This PPA provides daily builds of the Pipelight project pipelight-daily "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight-daily FALSE '"Pipelight : Michael Müller"' '"Pipelight allows one to run Silverlight inside a Linux browser using Wine Pipelight "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight FALSE '"pipelight-experimental : “Pipelight Dev Team” team"' '"Experimental packages for Pipelight  pipelight-experimental "' '"14.04 13.10 13.04"' pipelight/+archive/experimental FALSE '"pipelight-daily : “Pipelight Dev Team” team"' '"pipelight-daily "' '"14.10 14.04 13.10"' pipelight/+archive/daily FALSE '"pipelight-stable : “Pipelight Dev Team” team"' '"pipelight-stable "' '"14.10 14.04 13.10"' pipelight/+archive/stable FALSE '"libva : “Pipelight Dev Team” team"' '"libva "' '"13.10 12.10 12.04"' pipelight/+archive/libva
+ set +x


The above reveals how all the column components are expanded, properly quoted, by the use of "${lines[@]}".






share|improve this answer












From your description and code it sounds like you're looking for something like this:



    ss #1



To get a dialog that's constructed like this your original script needed to be augmented in a few key ways. For starters you need to move the call to construct the zenity dialog so that it's outside your while loop that's collecting all the data about the various PPAs.



The other thing lacking was a data structure to store all the bits about the PPAs that you were collecting. For this a Bash array makes the perfect "container" for this data.



lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")


This will continue to append the results that you collect via the while loop to an array called lines. This array is then given to zenity, it contains the column data.



Complete script



Here's the whole thing put together, which produced the above screenshot of the dialog.



#!/bin/bash

file="ppa-url-tmp"

lines=()
while IFS= read -r line; do
# display $line or do somthing with $line
title=$(curl https://launchpad.net/~$line | grep -e '<title>' | awk -F '<title>' '{print $2}' |
awk -F '</title>' '{print $1}' | sed 's/^/"/' | sed 's/$/"/')


description=$(curl https://launchpad.net/~$line | grep -e 'content=' | awk -F 'content="' '{print $2}' |
awk -F '.' '{print $1}' | tr -d '/>' | tr -d '"' | sed -e :a -e N -e 's/n/ /' -e ta | sed 's/^/"/' | sed 's/$/"/')


support=$(curl https://launchpad.net/~$line | grep -e '<option value=' | grep [0-9] | awk -F '(' '{print $2}' |
awk -F ')' '{print $1}' | sed -e :a -e N -e 's/n/ /' -e ta | awk '{print $1, $2, $3}' | sed 's/^/"/' | sed 's/$/"/' )

echo $title $description $support $line | uniq -u | tee -a /tmp/ppa
lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")

done <"$file"

zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"

if [[ "$?" != 0 ]]; then
exit
else

CHECK_INST=$(echo $CHECK | awk -F'|' '{print $5}')

sudo apt-add-repository $CHECK_INST
sudo apt-get -y update
sudo apt-get install $code
fi


Additional debugging tip



When you're unclear what something is doing in a Bash script reach for the commands set -x and set +x. These will enable and disable Bash's verbosity which can really help shed light on what's going on. Here's my zenity command with just verbosity turned up for it:



set -x
zenity --list --radiolist --title="Package installation." --text="Select package to be installed"
--width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA "${lines[@]}"
set +x


And here's what it looks like when I run ./myscript ...:



+ zenity --list --radiolist '--title=Package installation.' '--text=Select package to be installed' --width=800 --height=500 --column=In --column=Name --column=Description --column=Compatible --column=PPA FALSE '"pipelight-daily : Michael Müller"' '"This PPA provides daily builds of the Pipelight project pipelight-daily "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight-daily FALSE '"Pipelight : Michael Müller"' '"Pipelight allows one to run Silverlight inside a Linux browser using Wine Pipelight "' '"14.04 13.10 13.04"' mqchael/+archive/pipelight FALSE '"pipelight-experimental : “Pipelight Dev Team” team"' '"Experimental packages for Pipelight  pipelight-experimental "' '"14.04 13.10 13.04"' pipelight/+archive/experimental FALSE '"pipelight-daily : “Pipelight Dev Team” team"' '"pipelight-daily "' '"14.10 14.04 13.10"' pipelight/+archive/daily FALSE '"pipelight-stable : “Pipelight Dev Team” team"' '"pipelight-stable "' '"14.10 14.04 13.10"' pipelight/+archive/stable FALSE '"libva : “Pipelight Dev Team” team"' '"libva "' '"13.10 12.10 12.04"' pipelight/+archive/libva
+ set +x


The above reveals how all the column components are expanded, properly quoted, by the use of "${lines[@]}".







share|improve this answer












share|improve this answer



share|improve this answer










answered May 31 '14 at 21:18









slm

244k66504669




244k66504669












  • Thanks my friend! it worked, thanks for explain. This script going to help to much people.
    – davidva
    Jun 1 '14 at 8:27






  • 1




    @davidva - glad to have been of help and thanks for the interesting Q. Good luck!
    – slm
    Jun 1 '14 at 12:19










  • I attempted in Xubuntu doesn't read 'lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")" . This is the output: 'Syntax error: "(" unexpected (expecting "done").' I do not understand. But in Fedora, Arch Linux works :/
    – davidva
    Jun 2 '14 at 4:56












  • Solved! only change the first line #!/bin/sh to #!/bin/bash
    – davidva
    Jun 2 '14 at 5:30


















  • Thanks my friend! it worked, thanks for explain. This script going to help to much people.
    – davidva
    Jun 1 '14 at 8:27






  • 1




    @davidva - glad to have been of help and thanks for the interesting Q. Good luck!
    – slm
    Jun 1 '14 at 12:19










  • I attempted in Xubuntu doesn't read 'lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")" . This is the output: 'Syntax error: "(" unexpected (expecting "done").' I do not understand. But in Fedora, Arch Linux works :/
    – davidva
    Jun 2 '14 at 4:56












  • Solved! only change the first line #!/bin/sh to #!/bin/bash
    – davidva
    Jun 2 '14 at 5:30
















Thanks my friend! it worked, thanks for explain. This script going to help to much people.
– davidva
Jun 1 '14 at 8:27




Thanks my friend! it worked, thanks for explain. This script going to help to much people.
– davidva
Jun 1 '14 at 8:27




1




1




@davidva - glad to have been of help and thanks for the interesting Q. Good luck!
– slm
Jun 1 '14 at 12:19




@davidva - glad to have been of help and thanks for the interesting Q. Good luck!
– slm
Jun 1 '14 at 12:19












I attempted in Xubuntu doesn't read 'lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")" . This is the output: 'Syntax error: "(" unexpected (expecting "done").' I do not understand. But in Fedora, Arch Linux works :/
– davidva
Jun 2 '14 at 4:56






I attempted in Xubuntu doesn't read 'lines=("${lines[@]}" "FALSE" "$title" "$description" "$support" "$line")" . This is the output: 'Syntax error: "(" unexpected (expecting "done").' I do not understand. But in Fedora, Arch Linux works :/
– davidva
Jun 2 '14 at 4:56














Solved! only change the first line #!/bin/sh to #!/bin/bash
– davidva
Jun 2 '14 at 5:30




Solved! only change the first line #!/bin/sh to #!/bin/bash
– davidva
Jun 2 '14 at 5:30


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f132826%2fzenity-doesnt-display-all-list-with-variables%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Accessing regular linux commands in Huawei's Dopra Linux

Can't connect RFCOMM socket: Host is down

Kernel panic - not syncing: Fatal Exception in Interrupt