Home » Infrastructure » Unix » Helper Utility
Helper Utility [message #164298] Wed, 22 March 2006 19:22 Go to next message
PmT_
Messages: 2
Registered: March 2006
Junior Member
I am in a bind here. I am trying to create a shell script called 'helper' that displays a menu of options and after one is picked, it executes a command or program to carry out the desired alternative. When it finishes, control the loop around for another presentation of the menu. Now do not have the program re-invoke itself; make it a big loop and be sure to clear the screen before presenting the menu each time. Include a 'Quit' alternative on the menu to provide a way to terminate the menu program. Here it is the sample menu I would like to use:
UNIX Helper Utility

l - list file names in current directory
o - signon
f - signoff
d - display the time and date

q - quit

Each process that you select from the menu should print something on the screen so I can tell that it is running and make it execute long enough so I can see the message before the screen gets cleared again.

When up I need to add the following:
1. Main menu alternative that runs a process in the background, a long sleep may 100 secs.
2. Main menu alternative that invokes another bash shell so I can examine the process table, remove files, etc., until exit is typed, and will return to helper's menu.

Can anyone help? I am stumped! Sad
Re: Helper Utility [message #164312 is a reply to message #164298] Wed, 22 March 2006 21:11 Go to previous message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
This is a simple script, but it's not exactly what you want.
To get the menu to re-appear after each selection, you have to hit ENTER at the prompt. Also, it numbers the menu items rather than using mnemonics.

#!/bin/bash

LIST() {
        echo "Listing"
}

SIGNON() {
        echo "Signing On"
}

SIGNOFF() {
        echo "Signing Off"
}

DISPLAY() {
        echo "Displaying"
}

select choice in \
        "list file names in current directory" \
        "signon" \
        "signoff" \
        "display the time and date"
do
        echo "Choice: $choice"
        echo "Reply: $REPLY"

        case $REPLY in
        1)
                LIST
                ;;
        2)
                SIGNON
                ;;
        3)
                SIGNOFF
                ;;
        4)
                DISPLAY
                ;;
        *)
                break
                ;;
        esac
        sleep 3
        clear
done

Previous Topic: Oracle 10G Release 2 on Solaris
Next Topic: signon/signoff script???
Goto Forum:
  


Current Time: Thu Mar 28 06:46:48 CDT 2024