Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Menu Templates. 1

Status
Not open for further replies.

tijerina

Vendor
Mar 4, 2003
132
US
Would anybody have a good template for a menu.

I would like to create a menu using korn and was wondering if there was a template out there. This of course would be an interactive menu. I have some scripts that people in this forum have helped me with. I would like to now have the ability to run these scripts via a menu.

Any ideas?

 
This is what I have so far and it works good. I would like to add some enhancements, does anybody have any ideas on what I can do to make this menu look better?

Thank you all.

USAGE="usage: iverify"
PS3="Status of Files: " # here is the prompt
select menu_list in "ADAGER" "BACKPAK" "ITO/OVO" "LPD3K" "MAESTRO/CONMAN" "MPEX
" "OMNIDEX" "PRIVATE" "SCOMPARE/COMPARE" "SPEEDIT" "SUPRTOOL" "TAPES" "TIMEMACHI
NE" "TRAX" "UNISPOOL" "ALL PRODUCTS" "QUIT MENU"
do
case $menu_list in
"ADAGER")
./single;; # Running Report against the REGO account.
"ALL PRODUCTS")
./allfile;; # Running Report against all Third Party Accounts.
"QUIT MENU") # Exit
exit;;
*) # If user enter an unexpected number, print error message
print "You did not enter a valid number.";;
esac
done
 
I would use a here document to print the menu in a WYSIWYG mannner, with the case statement like above. Wrap it around a while loop for the exit condition and use function calls to execute commands, scripts, or even display sub-menus:

#! /bin/ksh
function call_a { print a;sleep 1;clear; }
function call_b { print b;sleep 1;clear; }
function call_c { print c;sleep 1;clear; }
function call_d { print d;sleep 1;clear; }

function call_num {
function call_1 { print 1;sleep 1;clear; }
function call_2 { print 2;sleep 1;clear; }
clear
while [[ $ANS1 != 3 ]] ; do
print "\033[01;34m\c"
print "**** Script.sh - Sub Menu ****"
print "\033[0m\c"

cat <<SUBMENU

Would you like to:

1) Run Program 1
2) Run Program 2
3) MAIN MENU

SUBMENU
print -n &quot;Choice: &quot;
read ANS1
case &quot;$ANS1&quot; in
1) call_1 ;;
2) call_2 ;;
*) clear ;;
esac
done
ANS1=
clear
}

### - Display main menu for the user to choose an option
clear
while [[ $ANS != 6 ]] ; do
print &quot;\033[01;34m\c&quot;
print &quot;**** Script.sh - Main Menu ****&quot;
print &quot;\033[0m\c&quot;

cat <<MAIN

Would you like to:

1) Run Program a
2) Run Program b
3) Run Program c
4) Run Program d
5) Run Numbers
6) EXIT

MAIN
print -n &quot;Choice: &quot;
read ANS
case &quot;$ANS&quot; in
1) call_a ;;
2) call_b ;;
3) call_c ;;
4) call_d ;;
5) call_num ;;
*) clear ;;
esac
done
exit

-jim
 
In my office, I use a custom compile of Lynx (most packages flat-out prevent local execution), and html menus with &quot;lynxexec&quot; and &quot;lynxprog&quot; links, and lots of sudo wrapping. The special lynx is also a login shell, so people who are supposed to use the menu are also prevented from breaking out of it.
 
keep it simple

#!/usr/bin/ksh

ORACLE=/home/ops/bin/Oracle
SYSTEM=/home/ops/bin/System
WORK=/home/ops/bin
MESSAGE=/home/ops/bin/message.ops


while true
do

clear
echo &quot;\n\t----------------------------------------------------&quot;
echo &quot;\t\t\t Ops Menu &quot;
echo &quot;\t----------------------------------------------------&quot;
echo &quot; &quot;
echo &quot;\t\t 1. Check Oracle Status&quot;
echo &quot;\t\t 2. Daily Operational Checks &quot;
echo &quot;\t\t 3. System Backup &quot;
echo &quot;\t\t 4. Shutdown and Reboot &quot;
echo &quot;\t\t 5. Message of the day &quot;
echo &quot;\t\t 6. Shutdown Oracle Database &quot;
echo &quot;\t\t 7. Startup Oracle Database &quot;
echo &quot;\t\t 8. Check Backup &quot;
echo &quot;\t\t 9. Follow RMS batchwork progress &quot;
echo &quot;\t\t10. Follow RMSO batchwork progress &quot;
echo &quot;\t\t11. View Batch Run Times &quot;
echo &quot;\t\t12. &quot;
echo &quot;\t\t13. &quot;
echo &quot;\t\t14. &quot;
echo &quot;\t\t15. Oracle Menu&quot;
echo &quot; &quot;
echo &quot;\t----------------------------------------------------&quot;
echo &quot;\t\t99. Exit &quot;
echo &quot;\t----------------------------------------------------&quot;
echo &quot;\tPlease enter your selection ..\b\b\c&quot;
read ans

case $ans in

1) $ORACLE/dbup.sh RMSQA
$ORACLE/dbup.sh rmsotwo;;
2) $WORK/checks.sh ;;
3) $SYSTEM/backup.sh ;;
4) $SYSTEM/sdown.sh ;;
5) $SYSTEM/motd.sh ;;
6) $ORACLE/orastop.sh ;;
7) $ORACLE/orastart.sh ;;
8) $SYSTEM/check_backup.sh ;;
9) $SYSTEM/rms_progress.sh ;;
10) $SYSTEM/rmso_progress.sh ;;
11) $SYSTEM/batch_work.sh ;;
15) /home/oracle/menu.sh ;;
SH) ksh ;;
99) exit ;;
*) $SYSTEM/error.sh ;;

esac
done --
| Mike Nixon
| Unix Admin
| ----------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top