Jump to content
 English      
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
     Forums advanced search
HP.com Home
IT Resource Center Forums > HP-UX > languages and scripting

Standard template / Menu - This thread has been closed

» 

IT Resource Center

» Login
» Register
» My profile
» Search knowledge base
» Forums
» Patch database
» Download drivers, software and firmware
» Warranty check
» Support Case Manager
» Software Update Manager
» Training and Education
» More maintenance and support options
» Online help
» Site map

Member icons
 
 HP moderator  HP moderator
 Expert in this area  Expert in this area
Member status
ITRC Pro ITRC Pro
250 points
ITRC Graduate ITRC Graduate
500 points
ITRC Wizard ITRC Wizard
1000 points
ITRC Royalty ITRC Royalty
2500 points
ITRC Pharaoh ITRC Pharaoh
7500 points
Olympian Olympian
20000 points
1-Star Olympian 1-Star Olympian
40000 points
2-Star Olympian 2-Star Olympian
80000 points
»  How to earn points
»  Support forums FAQs
Question status
Magical answer Magical answer
Message with a response that solved the author's question
Favorites status
Add to my favorites Add to my favorites
Delete from my favorites Delete from my favorites
This thread has been closed Thread closed
 

Content starts here
   Create a new message    Receive e-mail notification if a new reply is posted  Reply to this message
Author Subject: Standard template / Menu      Add to my favorites  This thread has been closed
lawrenzo This member has accumulated 500 or more points
Nov 7, 2009 09:13:48 GMT   

Hi all,

I am writing an operators menu and would like to present the users with a default display with the status of apps / processes / tasks displayed.

Is there a way I can display a standard template each time the user chooses an option so that each screen is the same for each menu?

I can probably create a function that echo's the template around the executed commands but is there a way to set this up so the menu is always in the outer sector of the display / output and then doesn't matter what is displayed in the middle or inner section?

Hope i've explained ok?

Thanks

Chris
Note: If you are the author of this question and wish to assign points to any of the answers, please login first.For more information on assigning points ,click here


Sort Answers By: Date or Points
Matti Kurkela This member has accumulated 7500 or more points
Nov 7, 2009 10:18:20 GMT  10 pts

Which scripting/programming language are you using?

This is a bit tedious to do efficiently using shell scripts.

You could print out your template, then move the cursor back up to the beginning of the content (using tput, see "man tput" for more info).
When you are moving to another menu, first move the cursor back to the beginning of the content and fill the content area with space characters: they will overwrite the old menu. Then move the cursor back again to write in the new menu.

You can optimize this by making all your menu content lines the same length (by filling them out with spaces), then just overwriting the old menu with the new one.

If you use a more advanced scripting language (like perl) or a real programming language, you can use the functions of the curses library to help you. Often the curses library will auto-optimize the output for you, automatically moving the cursor around to change only the characters that need to be changed. It also has a concept of "windows", which is exactly what you need here.

Man pages on curses:
http://docs.hp.com/en/B2355-60127/curses_intro.3X.html
http://docs.hp.com/en/B2355-60127/curses.5.html
(+ man pages for each individual curses function)

If you are unfamiliar with the curses library and wish to use it, I'd recommend reading a good book on curses programming. For example:

John Strang, Programming with curses, O'Reilly, ISBN 0-937175-02-1

Ncurses is a free extended re-implementation of curses. Its documentation might be useful with regular curses too:
http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/

MK
lawrenzo This member has accumulated 500 or more points
Nov 7, 2009 11:56:43 GMT    N/A: Question Author

Hi Matti,

I am open to suggestions to be honest and will take a look at the curse stuff for sure ...

I am familair with tput so thanks for the suggestions.

Chris.
OldSchool This member has accumulated 7500 or more points
Nov 7, 2009 16:04:58 GMT  4 pts

Chris,

a couple of years back, there was a related post here. one response included a set of awk scripts while another had a purely shell version. both used tput codes for hightlighting, and did pretty much what it sounds like you want to do.

I no longer have the link, it might be worth some searching around.

there also used to be a Tc/Tkl based menuing system available..that might have been at one of the GNU sites.
James R. Ferguson This member has accumulated 80000 or more points
Nov 7, 2009 16:56:37 GMT  10 pts

Hi Chris:

For pure simplicity, this thread has several variations of shell-based menu scripts:

http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=993074

Regards!

...JRF...
OldSchool This member has accumulated 7500 or more points
Nov 8, 2009 15:51:26 GMT  10 pts

And...one of the links in the post JRF noted to is the one I was referring to:

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=984784
lawrenzo This member has accumulated 500 or more points
Nov 9, 2009 11:54:04 GMT   Thread closed by author  

All,

Thank you very much - just what I was looking for and gives me something to work towards.

Regards

Chris
 
Create a new message    Receive e-mail notification if a new reply is posted   Reply to this message
 
 
Printable version
Privacy statement Using this site means you accept its terms
© 2009 Hewlett-Packard Development Company, L.P.