LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can we create a text Based Menu for complex Linux Operations (https://www.linuxquestions.org/questions/linux-software-2/how-can-we-create-a-text-based-menu-for-complex-linux-operations-113515/)

k41184 11-07-2003 02:33 PM

How can we create a text Based Menu for complex Linux Operations
 
I work as a student for the local internet service provider. We are setting up a new linux server. We would like to have a text based menu system that we can activate when logged in though ssh that will allow us to perform complex actions with only a few numbered or lettred key strokes. For example, we may have 7 steps to set up a new customer, and we want to be able to just type "n" and it will run through all those steps, prompting us at the right times for inputs. Or, we want to see if a user exits, rather than have to type in the search options, we need a menu option that we select, and all it asks for is the name, and then reports if they exists. What we would would like is a premade menu if possible that we can customize.

david_ross 11-07-2003 02:39 PM

Welcome to LQ.

Just write a bash script with a read option to take user input.

eekie 07-15-2009 01:55 AM

text menu
 
Nice but.... is there no example of such a menu?
I am setting up a mailserver with Ubuntu. I dont get out of the screen menu what i want.
Id like to build a menu to start and stop services and add users etc. in a simple way.

Help would be appriciated much

Eelco

jhwilliams 07-15-2009 01:57 AM

Quote:

Distribution: RH9, Fedora Core I,II,III
Yikes!

voyciz 07-15-2009 09:10 AM

Curses?

pixellany 07-15-2009 10:22 AM

Hmmm---an unusually high number of unhelpful replies........

Use something like kdialog or zenity to get the user input---Better yet, set it up so you can just click on the option you want.
**Oops--you said "text based"----for this just use the "read" command. (It has an option for the prompt text)

Then use a series of if statements (or maybe a "case" construct) to perform the specific operations

Regardless, you will need to think through what variants will be allowed in the user input. For example, if it's expecting "n", will it accept: "N", "new", "NEW", "nx"----etc.?

AND, include a "fall-through" so that something rational happens if the user types in something unexpected.

sycamorex 07-15-2009 10:37 AM

What about the 'dialog' command in bash? It would create a menu where you navigate via arrow keys. It is text based, isn't it. You could run it without X.

deadeyes 07-15-2009 03:12 PM

you probably want to uses ncurses

chrism01 07-15-2009 07:27 PM

Exapnding in jhwilliams post #4, you do realise all those distro versions are long dead and unsupported?
This includes no more security updates ...
You should (try) to get a more current distro eg Centos 5.3 or Fedora 11.

Here's a basic menu example http://techspalace.blogspot.com/2008...u-example.html
See also http://www.tldp.org/LDP/abs/html/testbranch.html

Fjdude 07-01-2010 11:32 AM

make easy menu
 
You could try:

<<mod edit: Link deleted--See below>>

You only have to install apache and some cgi's/binaries and you've got a webbased menu.
Adding menu's is making directories in "menu" path. Commands are files in the menu directory.

Example for "show files in a users home directory" :
-------------------------------------------
info%This command shows files in a users home directory
list%Select user%USR%cat /etc/passwd|cut -d: -f1
command%ls -la $(grep $USR /etc/passwd|cut -d: -f6)
-------------------------------------------

info is just text on screen.
list makes a dropdown
"Select user" is text before drop down
"USR" is the environment parm used for dropdown
"cat /etc/p...." is command to populate dropdown
command is the final command.

besides "list" you can use "check" for checkbox, "radio" for radiobutton and "text" free text input.

grtz Freddy

unSpawn 07-01-2010 11:58 AM

Quote:

Originally Posted by Fjdude (Post 4020726)
You could try:

That link only provides terse information. No D/L link for the SW is given. No licensing information is given. The contact link is a form asking for name and email. This is not the default way to promote or provide OSS.

catkin 07-01-2010 12:36 PM

How about starting by writing the back-end scripts? That way you would get the benefit of them before worrying about the menu and all for the price of typing the script name at the command prompt. It's a stage you will go through during development anyway. For the menus, the bash select command is simple, extensible and may be "good enough", certainly for phase I before going for a "pretty" menu with ncurses or whatever.

pixellany 07-02-2010 08:50 AM

Fjdude;

Please do not post links that do not directly provide useful information or that could simply be seen as advertising.

Fjdude 07-26-2010 01:53 PM

hi,
 
Quote:

Originally Posted by pixellany (Post 4021717)
Fjdude;

Please do not post links that do not directly provide useful information or that could simply be seen as advertising.

Well, i am not selling, so.... advertising? I made the dialogs myself and the internet site is not done yet. If you had filled out the form i would have send you the tar-file (cgi-scripts) with install instructions. Free to test!

Greetz

elfoozo 07-26-2010 06:55 PM

k41184,

I used this as a starter for making my own menu options:

http://bash.cyberciti.biz/decision-m...-shell-script/


All times are GMT -5. The time now is 09:36 PM.