<< Environmental Variables are not set when script completes >>

Hi Team,

I have a wrapper script which i have pasted below, it internally calls one python script to generate Environmental in a file called /home/oracle/myenv.sh, when i execute this script via wrapper script, its not reflecting in my current session, still showing old env variables. any thoughts or ideas ?

$ cat wrapper.sh

#!/bin/bash

[[ -f /home/oracle/myenv.sh ]] && rm -rf /home/oracle/myenv.sh

Pypath=`ls /usr/bin/python[0-9]* | sort -n | sed -n '\$ s/\([a-z0-9./]*\).*/\1/p'`

${Pypath} /home/oracle/set_ora_env.py

cd /home/oracle

[[ -f /home/oracle/myenv.sh ]] && . ./myenv.sh && echo "NOTE: enviroimental variables set for sid"
$ cat /home/oracle/myenv.sh
#!/bin/bash
export ORACLE_SID=GRID
export ORACLE_HOME=/oracle/grid/11.2.0.4
export PATH=$PATH:/oracle/grid/11.2.0.4/bin
export LD_LIBRARY_PATH=/oracle/grid/11.2.0.4/lib

My guess is you are executing "wrapper.sh" instead sourcing.

# try
. ./wrapper.sh

#instead
./wrapper.sh
1 Like

Thanks a lot @clx perfectly Working !!!

2 Likes