View Full Version : Basic zenity+sqlite sintax

December 3rd, 2008, 03:17 PM
I want to make a script with zenity, so it prompts for an action where the options are retrieved from a sqlite database.

The standalone zenity code should be something like this:

zenity --list --height=360 --width=300 --text "Select an option" --radiolist --column "Pick" --column "Options" 1 'Option 1' 2 'Option 2'

Here is the script integrated with the database:


OPTIONS=$(sqlite3 ~/mydatabase.sqlite "select [string] from selector")

CAT=$(zenity --list --height=360 --width=300 --text "Select an option" --radiolist --column "Pick" --column "Options" ${OPTIONS})

echo "$CAT"

Where the database entries are:

rowid string
1 1 Option1
2 2 Option2

The resulting options prompt looks fine like this:

http://img142.imageshack.us/img142/917/screenshotselectitemsfrpr4.th.png (http://img142.imageshack.us/img142/917/screenshotselectitemsfrpr4.png)

and the result of

echo "$CAT"

is also correct


The problem is when I use values with spaces in the database string column like this:

rowid string
1 1 Option 1
2 2 Option 2

The prompt will be completely messed up like this:

http://img139.imageshack.us/img139/3250/screenshotselectitemsfrwp0.th.png (http://img139.imageshack.us/img139/3250/screenshotselectitemsfrwp0.png)

So how do I fix this? Or should I use another method?