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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unix script menu not working

Status
Not open for further replies.

eb222

MIS
Mar 12, 2007
11
NL
Im using below script on sun and it just comes back to the command prompt without running any env variables. the env variables exist in the correct directories and they run manually no problem.


#!/bin/sh
MAIL=/usr/mail/${LOGNAME:?}

# Set up the shell environment:
#set -u
#trap "echo 'logout'" 0
stty erase ^H

# Set up the shell variables:
EDITOR=vi
export EDITOR

TERM=vt220 ; export TERM
ANS='X';
while [ "$ANS" != "EXIT" ]
do
tput clear
clear
#echo " `date`"
#echo
echo " [SITE] Development Environment"
echo
echo " e-Business Suite"
echo
echo " ==================================="
echo
echo
echo " 1. ERPSIT2 Environment (ERPSIT2)"
echo
echo " 2. ERPSIT3 Environment (ERPSIT3)"
echo
echo " 3. ERPMNT2A Environment (ERPMNT2A)"
echo
echo " 4. ERPRUA6A Environment (ERPRUA6A)"
echo
echo " 5. ERPDES8 Environment (ERPDES8)"
echo
echo " 6. ERPDES6 Environment (ERPDES6)"
echo
echo " 7. ERPUAT3 Environment (ERPUAT3)"
echo
echo " 8. ERPRUA5A Environment (ERPRUA5A)"
echo
echo " 9. UNIX PROMPT"
echo
echo
echo " Please make your selection : \c"

read ANS

loop=Y


if [ "$loop" = "Y" ]; then
case $ANS in

1) . /home/viewer/ERPSIT2_dbenv
cd $ORACLE_HOME
ANS="EXIT"
;;
2) . /home/viewer/ERPSIT3_dbenv
cd $ORACLE_HOME
ANS="EXIT"
;;
3) . /home/viewer/ERPMNT2A_dbenv
cd $ORACLE_HOME
ANS="EXIT"
;;
4) . /home/viewer/ERPRUA6A_dbenv
cd $ORACLE_HOME
ANS="EXIT"
;;
5) . /home/viewer/ERPDES8_dbenv
cd $ORACLE_HOME
ANS="EXIT"
;;
6) . /home/viewer/ERPDES6_dbenv
cd $ORACLE_HOME
ANS="EXIT"
;;
7) . /home/viewer/ERPUAT3_dbenv
cd $ORACLE_HOME
ANS="EXIT"
;;
8) . /home/viewer/ERPRUA5A_dbenv
cd $ORACLE_HOME
ANS="EXIT"
;;
9) echo
exit
;;
*) echo
echo " Invalid selection - Please try again \c"
sleep 1
;;
esac
fi

done
 
You seem to know about the . or "source" operator. Trouble is, you need to source this menu also, otherwise all env vars will be set in the menu's subshell end not in your login shell.

But then in option 9, change to 'ANS=EXIT' instead of 'exit', or you'll get logged out after choosing 9.

You might also try to program this menu as a shell function, then it should also work, again change the 'exit' in option 9 to 'return'...


HTH,

p5wizard
 
thanks

the suggestions have worked

very much appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top