• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

unix script

can someone tell me why my unix script does not work?
when I run it and then do an

env|grep ORA

nothing comes back so I know it is not working

system is aix 6.1
I use Kornshell


#!/bin/ksh
#Terminal settings
REV=`tput rev`
BLINK=`tput blink`
BEL=`tput bel`
BOLD=`tput bold`
ULINE=`tput smul`
DIM=`tput dim`
OFF=`tput sgr0`
MACH=`uname -n`
#
 while true
 do

clear
echo "Select which oracle database you would like to user..."
echo
echo "1)  parprd"
echo "2)  karprd"
echo
echo "Enter Choice: \c"
read CHOICE
echo;echo
case $CHOICE in
1) echo "$REV$BOLD Setting env for parprd ... $OFF"
echo
sleep 1
export ORACLE_SID=parprd
export ORACLE_BASE=/oracle/product
export ORACLE_ADMIN=/oracle/product/admin
export ORACLE_HOME=/oracle/product/10.2.0
export PATH=$ORACLE_HOME/bin:$PATH
echo $ORACLE_SID
break;;
2)echo "$REV$BOLD Setting env for karprd ... $OFF"
echo
sleep 1
export ORACLE_SID=karprd
export ORACLE_BASE=/u01/oracle/product
export ORACLE_ADMIN=/u01/oracle/product/admin
export ORACLE_HOME=/u01/oracle/product/11.2.0
export PATH=$ORACLE_HOME/bin:$PATH
echo $ORACLE_SID
*) echo "Invalid choice..."
echo "Press <CR> to continue."
read ans
continue
esac
don
echo
#
0
bkreynolds48
Asked:
bkreynolds48
  • 2
1 Solution
 
woolmilkporcCommented:
You must "source" the script (i.e. run it as a part of your current shell).
A script run as a child process as usual will never change the environment of its parent!

"Source" a script by calling it with ". " (dot space) prepended:

.   /path/to/script

The third from last line of the posted code must read "done" instead of  "don", by the way.
0
 
bkreynolds48Author Commented:
yes I had copy/pasted the script and missed the e on done - but it is there

is there a way to source the script without doing the . /path/to/script?  I put it in my $HOME/bin dir
0
 
woolmilkporcCommented:
Do you mean:

.   $HOME/bin/scriptname

?  No problem!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now