LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-16-2008, 04:45 PM   #1
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Rep: Reputation: 19
Zenity Checkbox extracting Variables


I'm trying to get certain variables from a zenity script.

I have a code below.
Code:
#!/bin/sh
hello=$(zenity --list --checklist --title "Testing checkbox." --text "Checkbox test." --column "" --column "Nice" False 1st False 2nd False 3rd False 4th False 5th)
If someone picks 1st and 3rd lets say. Then $hello echo's 1st|3rd

How do I create a variable for 1st and one for 3rd? I kinda want to split up that so I can run multiple scripts for each checkbox.

Thanks,
Klesla
 
Old 09-16-2008, 07:34 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
You could split them out with "${hello//|/ }" and a for loop or case statement or use an array: 'hello=(${hello//|/ })' and access elements?
 
Old 09-17-2008, 11:02 AM   #3
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by unSpawn View Post
You could split them out with "${hello//|/ }" and a for loop or case statement or use an array: 'hello=(${hello//|/ })' and access elements?
Thanks for the reply.

However when I run it with the code hello=(${hello//|/ }), it gives me 1st3rd. How do I have it split the variables with a for or array statement?

Thanks again.
 
Old 09-17-2008, 01:43 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Code:
somethingTo() { echo $@; }
# You could:
for item in ${hello//|/ }; do somethingTo $item; done
# or with an array:
hello=(${hello//|/ }); for (( element = 0 ; element < ${#hello[@]}; element++ )); do somethingTo ${hello[$element]}; done
# or use a case statement instead of somethingTo.
# Maybe looks convoluted at first, but once you get the hang of it it really isn't.
 
Old 09-17-2008, 04:25 PM   #5
webaccounts
Member
 
Registered: May 2008
Location: Columbus Ohio
Distribution: CentOS 5.9/6.4 x64
Posts: 44

Original Poster
Rep: Reputation: 19
Fantastic. Thanks, that got me started.
 
Old 09-18-2008, 01:09 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by webaccounts View Post
Fantastic. Thanks, that got me started.
Good to hear. You might want to use some more

Code:
function help() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html 
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html 
http://www.tldp.org/LDP/abs/html/ "; }
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
JS IE: checkbox.checked doesn't work eantoranz Programming 8 07-27-2011 03:59 AM
question/ answer checkbox for each post schneidz LQ Suggestions & Feedback 1 02-19-2007 03:56 PM
PHP,JAVASCRIPT and CheckBox aznita Programming 2 06-17-2005 05:33 AM
3D Acceleration checkbox grayed out itsjustme Linux - General 3 06-24-2003 08:24 PM
apache user/password checkbox jdubu Linux - Networking 1 05-24-2002 08:12 AM


All times are GMT -5. The time now is 11:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration