Showing results for 
Search instead for 
Do you mean 

Menu programming

SOLVED
Go to Solution
Honored Contributor Honored Contributor

Menu programming

Hi @ll,

what is the best way to programm a menu like the SAM. in which language is SAM programmed?

I prefer Perl or KSH. exists in Perl a module for a menu.

I saw in KSH exist something like:

select what in "Point1" "Point2"; do
case $REPLY in
1)
echo "foo bar"
break
;;
2)
echo "foo bar 1"
break
;;
esac
done

but exist something who looks more professional than that?

Thanks & Regards



1 ACCEPTED SOLUTIONS
Honored Contributor Honored Contributor

Re: Menu programming

An example of what we can do in ksh
16 REPLIES
Honored Contributor Honored Contributor

Re: Menu programming

Hi,

If you add a new in SAM, it is shell script based.
Honored Contributor Honored Contributor

Re: Menu programming

Exist somewhere an example script that i can adapt to my rules?
Honored Contributor Honored Contributor

Re: Menu programming

Hi Try /usr/dt/bin/dtksh
examples are in /usr/dt/examples/dtksh
Honored Contributor Honored Contributor

Re: Menu programming

Or do you mean a curses oriented menu?
Honored Contributor Honored Contributor

Re: Menu programming

For Sam I believe, it is mainly in C, only a few parts are scripts.
it uses a undocumented library called libObam which does curses or X11 depending if DISPLAY is defined. In any case it is not usable
Honored Contributor Honored Contributor

Re: Menu programming

Here's a text based one I use - shell based - this one is called lp.mnu:

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Honored Contributor Honored Contributor

Re: Menu programming

Thanks @ll

@Geoff: that's what I searched

the dtksh is also nice, but i need a textbased menu. I found this thread for dtksh:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=101310

has someone an idea whether exists also something in perl?

Regards
Honored Contributor Honored Contributor

Re: Menu programming

default perl is not having switch case statement as like shell prompt. If you want text based on terminal then you can go with case;do done statements itself.

-Muthu
Easy to suggest when don't know about the problem!
Honored Contributor Honored Contributor

Re: Menu programming

You can use Perl with add-on modules to program menu driven apps. Check www.cpan.org for more information

http://search.cpan.org/~corliss/CursesWidgets-1.997/Widgets/Menu.pm

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Esteemed Contributor Esteemed Contributor

Re: Menu programming

Hi,
if you are interested I use a menu driveen created by awk. It's a general purpuose: you write in a file the line you want to see in teh menu and the associated command and nothing else.
Let me know if you want it and I'll attach.
(I'd like to avoid to attach unuseful scripts)

HTH,
Art
Honored Contributor Honored Contributor

Re: Menu programming

An example of what we can do in ksh
Honored Contributor Honored Contributor

Re: Menu programming

Thanks again @ll

@Art: it would be nice if you could attache the awk script, thx

Highlighted
Honored Contributor Honored Contributor

Re: Menu programming

Here is an example using AWK,

http://www.iiug.org/software/archive/dbamenu
http://www.gnu.org/software/gawk/manual/gawkinet/gawkinet.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Esteemed Contributor Esteemed Contributor

Re: Menu programming

In the zip file there are the script and and example of the use.
The script to run is Menu.ksh.
HTH,
Art
Honored Contributor Honored Contributor

Re: Menu programming

Hi All,

Just a remark,

if you press space it toggles the line.
If you want to suppress that feature just comment the " ") case in the switch.
I saw too that the "tput cnorm" is not the right value to clear the bold mode, It is better to use "tput sgr0" to clear all the atributes at its place.

Also, the trick used it to set the non canonical mode with a timeout of (200ms) time=2 and min=1 (at least a charactere).
Sometimes it doesn't work as expected, so raise min to 3.
stty -icanon -echo min 3 time 2 ;
This will wait for 3 characteres or a inter timeout of 200ms
Honored Contributor Honored Contributor

Re: Menu programming

You could check out the "keysh" shell. It is somewhat programmable. Though it doesn't present a menu, it does use function keys to select tasks. Do a "man keysh" for more info.

Rod Hills
There be dragons...