sadm_template_menu.sh

1 minute read

$SADMIN/bin/sadm_template_menu.sh - v1.5
Posted 2021-04-30 - Updated 2021-04-32
Supported on Linux, Aix, MacOS

NAME

sadm_template_menu.sh - Using SADMIN shell menu template

SYNOPSIS

sadm_template_menu.sh [-d 0-9] [-h] [-v]

DESCRIPTION

The best way to become familiar the menu builder, is to run the “sadm_template_menu.sh” script.

$ sudo $SADMIN/bin/sadm_template_menus.sh

Menu template

EXAMPLE

Here is some portion of the code in “sadm_template_menu.sh”, you want to modify to create your own menu.

# Display Main Menu     
while :
  do
  sadm_display_heading "Your Menu Heading Here"               # Std SADMIN Menu Heading
  menu_array=("Your Menu Item 1" "Your Menu Item 2" "Your Menu Item 3" "Your Menu Item 4" )
  sadm_display_menu "${menu_array[@]}"                        # Display menu Array
  sadm_choice=$?                                              # Choice is returned in $?
  case $sadm_choice   in                                            
      1) sadm_mess "You press choice number $sadm_choice"
         ;;
      2) sadm_mess "You press choice number $sadm_choice"
         ;;
      3) sadm_mess "You press choice number $sadm_choice"
         ;;
      4) sadm_mess "You press choice number $sadm_choice"
         ;;
     99) # Option Quit -                                      # 99 = [Q],[q] was pressed
         break                                                # Break out of the loop
         ;;
      *) # Invalid Option #                                   # If an invalid key press
          sadm_mess "Invalid option"                          # Message to user
         ;;
  esac
  done

OPTIONS

Options Description
[ -d 0-9 ] Set debug level from 0 to 9 (Default is 0)
[ -h ] Display this help and exit.
[ -v ] Output version information and exit.

ENVIRONMENT

  • The “$SADMIN” environment variable must be defined and contains the root directory of the SADMIN tools (normally /opt/sadmin). It should be already done, the setup script have updated the ‘/etc/profile.d/sadmin.sh’ and the ‘/etc/environment’ files.
  • The SADMIN configuration file, is needed and loaded in memory at the beginning of every scripts. This file should already exist and contains your SADMIN configuration and preference setting.
  • For Shell script the Shell Library is used and for Python script the Python Library is used.

EXIT STATUS

Exit Code Description
0 An exit status of zero indicates success.
1 Failure is indicated by a nonzero value, typically ‘1’.

AUTHOR

Jacques Duplessis
Any suggestions or bug report can be submitted at the support page

Copyright © 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
This is free software, you are free to change and redistribute it.
There is NO WARRANTY to the extent permitted by law.

SEE ALSO

sadm_template.sh - Using SADMIN Shell script template
sadm_template.py - Using SADMIN Python script template