LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-18-2010, 05:01 PM   #1
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Rep: Reputation: 16
Script Running with different Selections


Hi....

i have two scripts called:
type & selecttype.
In type i have only the name of the products ex.: product1 & product2. Now, i am going to ADD product3 which includes productA, productB, productC, productD, productE, productF. so my new type script (menu) looks as below:

1) product1
2) product2
3) product3

and my current selectype looks as below ( which is set only for product1 & product2)my question is how can include the new product3 with all other multiple selections (productA, productB, productC, productD, productE, productF) into my current selectype as below:


#!/bin/sh
echo SELECTTYPE
export -n selecttypechoice

if [ "${upgrade}" == "yes" ] ; then
selecttypechoice=${upgrade_type}
else
[ -a ./types ]
if [ $? = 0 ] ; then
#### Select Type from types file
echo --title \"$installproductchoice Server Role\" --menu \"Select Role to install\" 20 48 6 > /tmp/selecttype.dialog
for vpackages in `cat types`; do
if [ "$typesexception" = "" ] ; then
echo \"$vpackages\" Role >> /tmp/selecttype.dialog;
else
echo $typesexception | grep -i "$vpackages"
if [ $? = 0 ] ; then
echo .
else
echo \"$vpackages\" Role >> /tmp/selecttype.dialog;
fi
fi
done;

dialog --file /tmp/selecttype.dialog 2> /tmp/selecttype.choice
if [ $? = 0 ] ; then
export selecttypechoice=`cat /tmp/selecttype.choice`;
else
export -n selecttypechoice;
fi
reset
echo selecttypechoice $selecttypechoice
if [ "$selecttypechoice" = "" ] ; then
echo Aborted: User Aborted while selecting a $installproductchoice Role
echo .........Try again !!
exit ;
fi
fi
fi


**** Thank you in advance for your help!!
 
Old 03-18-2010, 05:45 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hi, welcome to LQ!

And the question/problem was .... ?! :}


Cheers,
Tink
 
Old 03-18-2010, 06:16 PM   #3
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 70
Quote:
Originally Posted by NetRock View Post
my question is how can include the new product3 with all other multiple selections (productA, productB, productC, productD, productE, productF) into my current selectype as below


But seriously mate, you're doing this allll wrong. You obviously have some (though not a lot, no offence intended) experience, and so it'll come to you.

But yes, scrap all of this and think about what you're doing. Consider shifting away from bash.
 
Old 03-18-2010, 08:19 PM   #4
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
Thanks for your feed-back. But i CANNOT shift away...!!! you see when users select option: "3)product3" in the menu, they should see another menu with all the sub categories. So type would include options: 1)product1 2)product2 3)product3 when they select No.3 they should see product A-E. for that need to modify posted script "selecttype". this script is part of working production so can not shift away from bash. i need to get it right to add the new changes. So users have the option to select the new product with all the sub product. need more info. please let me know. THANKS ALL
 
Old 03-18-2010, 09:56 PM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Hi Netrock

Whilst I don't have an issue helping to make the changes necessary to ad product3 how you wish,
I would have to agree with at least part of what jamescondron has said, namely "scrap all of this and think about what you're doing".

The reason I say this is:

1. Outdated / deprecated options used (ie [ -a ./types ])
2. Further to last example, you do the test and then do nothing with it but then test the return $? (kind of a waste)
3. Testing of uninitialised variables (bad habit) eg if [ "$typesexception" = "" ] (plus should possibly be using -n or -z here)
4. echo . -- not really sure the benefit (could be wrong on this one)

Until these and possibly others, as only had a quick look, are fixed, adding to this would just compound the problems.

Lastly, probably would have this moved to programming forum so you could get better assistance.
 
Old 03-19-2010, 01:40 AM   #6
NetRock
Member
 
Registered: Mar 2010
Posts: 134

Original Poster
Rep: Reputation: 16
Thank you Grail for your feedback. as i am talking to you right now i am not in the position to do facelift on this one. i need to add & let the production rolls. "SHOW MUST GO ON". but once get my learning advance to the point where i can write Bash Script, I WILL CHANGE ALL THIS.
 
  


Reply



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
Kernel Selections carlosinfl Linux - Kernel 3 06-18-2007 10:51 PM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 09:10 PM
Modifying GRUB selections gizza23 Linux - Software 3 07-13-2005 07:19 AM
Gimp help - selections cneedham Linux - Newbie 1 02-19-2005 02:01 AM
undo selections in dselect phil_anderer Linux - Newbie 0 02-15-2004 11:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:43 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
Open Source Consulting | Domain Registration