Operating System - HP-UX
1751977 Members
4541 Online
108784 Solutions
New Discussion юеВ

Need help with some shell programming ideas -- Menu driven

 
MAD_2
Super Advisor

Need help with some shell programming ideas -- Menu driven

I have this korn shell script I am developing which will be menu driven. However, recently I have found a few brick walls on the way:

1. I would like to provide a screen which has the output from results parsed from a file. On that screen I would like to allow the user to arrow up/down through the options, and select the desired "server name" as these are shown to be available (example of what I would like to accomplish shown in file "ScreenSelectionSample.txt").

The "server names" come from a file that I would need to parse to get the results from.
The file format looks like the attached example (file attached named "parsefile_Extract.txt" -- only a sample portion example)

Here are the few problems I have:

1. How do I enable my screen to do selections (arrow up/down) based on displayed results as example provided (only left column where the desired server name is shown)

2. How do I parse the file to obtain not only the server name, but also the minimum number of servers to run, the max, the number actually running (explained below and shown in processes snapshot), and the IDs that are still available to fire up some more -- I need to add coding that shall permit adding/removing more of these services, based on limits provided in the file.

For example:
The processes file I am providing below has for:
service2Svr_X0| NABEAPP| 100| 2| 2| 8|

This means, a 2 minimum required, 2 have started, 8 is the max, the IDs to be used are 100-107 (100 and 101 already running):

userapp 27142 1 0 May 11 ttyp6 0:25 service2Svr_X0 -g 2 -i 100 -u hostXX -U /apath/app/c
userapp 27271 1 0 May 11 ttyp6 0:24 service2Svr_X0 -g 2 -i 101 -u hostXX -U /apath/app/c

I may need to break down this since there are a few questions here, but would like to start with the menu portion. Thanks for any help, I shall give points as each portion is answered.

Once again, any ideas are welcome (and no, I don't have perl experience, but possibly next month after I take the course, when I may need to convert this whole shell script to perl).
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
7 REPLIES 7
MAD_2
Super Advisor

Re: Need help with some shell programming ideas -- Menu driven

1st file attachment:
Menu concept...
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
MAD_2
Super Advisor

Re: Need help with some shell programming ideas -- Menu driven

2nd attachment:
File to be parsed
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
MAD_2
Super Advisor

Re: Need help with some shell programming ideas -- Menu driven

3rd attachment:
List of processes...
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Geoff Wild
Honored Contributor

Re: Need help with some shell programming ideas -- Menu driven

I don't know about the arrows....but here's a "simple" menu driven script - where user selects a "letter" from the menu:

Fri May 13 11:54:22 MDT 2005

UNIX LP Support Menu

Please Select:

a. Check printer status
b. Add Printer
c. Delete Printer
d. Disable a Print Queue
e. Enable a Print Queue
f. Backup the Spooler Configuration
g. Restore the Spooler Configuration
h. Check the Print Spooler log
i. Check the iprprtpkg log
j. Check the iprprtpkg status


x. Exit



Select by pressing the letter and then ENTER



It might give you some ideas...

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.
MAD_2
Super Advisor

Re: Need help with some shell programming ideas -- Menu driven

Thanks for the quick response Geoff, and for the attached sample (I am sure that I'll be able to use it somehow later). I am actually following that concept for my first few menu driven screens for this program, which are required in order to set other requirements before getting to the meat of it.

However, my main issue is that the "menu" per say that I would like to put together will need to be based on the available services as prescribed by the parsed file and the applicable services that are already running. If possible I would like to allow the user to select an option instead of making them type anything at all in this menu.

Thanks!

Adam.
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
Leif Halvarsson_2
Honored Contributor

Re: Need help with some shell programming ideas -- Menu driven

Hi,

I don't belive it is possible to use arrow keys for selecting witout using C-code (at least not possible with shell scripts).

I have written some menu-scripts myself bot not found any way without typing something from the keyboard.

Have a look at the "select" statement in sh/ksh. It is intended for menu selections.
Rick Garland
Honored Contributor

Re: Need help with some shell programming ideas -- Menu driven

You mention no perl experience but you may be converting this script next month.

This is a perl script that is presented to users in a menu format. I am using numbers for the menu options - you can use letters if you like, just make appropriate changes. To have the scroll capabilities with the corresponding arrows as selection items will take much, much more work. Probably more work than you want to do.

The example you posted seems mainly for printers. Attached you will find a perl script written for helpdesk personnel to allow them to do some of the functions. Note that the sudo utility is incorporated into this script - to allow the non-root users the ability to execute some lp commands.

This script can be modified to suit your needs.