1753943 Members
9362 Online
108811 Solutions
New Discussion юеВ

Re: linux shell menu

 
wobbe
Respected Contributor

linux shell menu

A long time ago when I was playing testdrive and civilization on my Cannon 286 I had this easy to configure menu that would launched all these great games. Now I would like to have something simmilar to run all kind of linux tools/scripts.
4 REPLIES 4
Joel Kammet
Occasional Advisor

Re: linux shell menu

Install the ncurses library and have a look at this tutorial: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

The library (and the tutorial) include sample code for menus which you can tailor for your application.
Matti_Kurkela
Honored Contributor

Re: linux shell menu

Learning NCURSES programming just to create a few text-based menus would seem a bit... hardcore to me.

Most Linux distributions include a "dialog" tool that can be used in scripts to create various text-based menus and other dialog boxes.

Use your distribution's package manager to make sure the "dialog" package is installed, then see the documentation that comes with it. At least in Debian, there are a lot of usage examples in /usr/share/doc/dialog/examples, and of course the manual is available with the standard "man dialog" command.

MK
MK
wobbe
Respected Contributor

Re: linux shell menu

I have not found anything on the internet so I guess I will give "dialog" a try. I should be able to do what I want.
Viktor Balogh
Honored Contributor

Re: linux shell menu

you can write a shell script like this:

###############################
#!/bin/sh

amenu="A. DAILY LOGS CHECKING" ;
bmenu="B. USER-ID MANAGEMENT " ;
cmenu="C. MASTER OFF USER-ID " ;
dmenu="D. PRINTER MANAGEMENT " ;
emenu="E. BACKUP " ;
fmenu="f. HOUSEKEEPING " ;
gmenu="g. PERFORMANCE MONITORING " ;
hmenu="h. SYSTEM INFO ";
imenu="I. OTHERS ";

badchoice () { MSG="Invalid Selection ... Please Try Again" ; }

apick () { ./dailymenu.txt ; }
bpick () { usridmenu.txt ; }
cpick () { masteroffmenu.txt ; }
dpick () { printermenu.txt ; }
epick () { backupmenu.txt ; }
fpick () { housekeepingmenu.txt ; }
gpick () { performancemenu.txt ; }
hpick () { sysinfomenu.txt ; }
ipick () { othersmenu.txt ; }



themenu () {

clear
echo `date`
echo
echo
echo "Please Select:"
echo
echo $amenu
echo $bmenu
echo $cmenu
echo $dmenu
echo $emenu
echo $fmenu
echo $gmenu
echo $hmenu
echo $imenu
echo "J. Exit"
echo
echo $MSG
echo
echo Select by pressing the letter and then ENTER ; }

MSG=

while true
do

themenu


read answer


MSG=

case $answer in
a|A) apick;;
b|B) bpick;;
c|C) cpick;;
d|D) dpick;;
e|E) epick;;
f|F) fpick;;
g|G) gpick;;
h|H) hpick;;
i|I) ipick;;

j|J) break;;

*) badchoice;;

esac

done
###############################


the idea is not mine, look here:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1342366
****
Unix operates with beer.