Results 1 to 5 of 5
I would like to create a menu. It would consist of,
choices 1-10 with specific commands associated. So what I am thinking, is I need to have a menu with ...
- 07-28-2006 #1Just Joined!
- Join Date
- May 2006
- Posts
- 47
How could I create a bash menu script?
I would like to create a menu. It would consist of,
choices 1-10 with specific commands associated. So what I am thinking, is I need to have a menu with 1 thru 10 multiple choice and then commands like
read x
If x=1 Then
ssh A
else if
x=2 Then
ssh B
else if
I know thats not neccisarilly the right way. My question is if anyone could help with some input on the best way to do this? How do I create the menu, is it one long echo command? Is If then the best way and what is the correct syntax?
One last question, is there a way to automate in a script suing to another user, for instance I know you can put su user but unless you are root it asks for a password, is there way to automate the entry of the password?
- 07-28-2006 #2
You could use the case command instead of the many if else constructs.
Use an echo, the format of which should be carried over from the script.
- 07-28-2006 #3Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,116
Hi.
Another method is to use select, noted in the tutorial:
Best wishes on your learning ... cheers, drlThe select construct, adopted from the Korn Shell, is yet another tool for building menus.
Example 10-29. Creating menus using select
http://www.tldp.org/LDP/abs/html/testbranch.htmlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 01-19-2011 #4Just Joined!
- Join Date
- Jan 2011
- Posts
- 10
Thanks guys for the quick responce
Im going to atempt it tonight. Would it be fine if i post the script that i have created once done and you could tell me if its good to go
- 01-19-2011 #5forum.guy
- Join Date
- May 2004
- Location
- arch linux
- Posts
- 18,090
oz
→ new members/users: read this first | new member faq
→ no private messages requesting computer support - post them on the forums!
→ please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.




