zenity doesn't display all list with variables
up vote
2
down vote
favorite
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
zenity
add a comment |
up vote
2
down vote
favorite
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
zenity
@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
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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
zenity
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
zenity
zenity
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
add a comment |
@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
add a comment |
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:
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[@]}"
.
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
add a comment |
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:
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[@]}"
.
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
add a comment |
up vote
1
down vote
accepted
From your description and code it sounds like you're looking for something like this:
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[@]}"
.
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
add a comment |
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:
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[@]}"
.
From your description and code it sounds like you're looking for something like this:
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[@]}"
.
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
@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