Home » Infrastructure » Unix » Env variables not being set via a shell script. (Sun Solaris 5.10)
Env variables not being set via a shell script. [message #294253] Wed, 16 January 2008 23:50 Go to next message
vjeedigunta
Messages: 201
Registered: March 2005
Location: Hyderabad
Senior Member

Hello,
I have a shell script which has the below lines

Quote:
#!/bin/ksh
SHELL=/usr/bin/ksh;export SHELL
EDITOR=vi
export EDITOR
ORACLE_BASE=/database_1/oracle
export ORACLE_BASE
ORACLE_HOME=/database_1/oracle/product/9.2.0.8
export ORACLE_HOME



after I execute the shell script.. it doesnt throw any errors but I see that env variables are not set as in the script .. if i run the same commands outside the script, its working fine without any issue ..

What could be the issue .. ?

Please advice,
-Sai
Re: Env variables not being set via a shell script. [message #294272 is a reply to message #294253] Thu, 17 January 2008 00:52 Go to previous messageGo to next message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
How do you see that?
Copy and paste what you execute.

Regards
Michel
Re: Env variables not being set via a shell script. [message #294502 is a reply to message #294253] Thu, 17 January 2008 17:31 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
This problem & solution have NOTHING to do with Oracle.
>What could be the issue .. ?
PEBKAC for sure.
You need to source the file not execute it.
Re: Env variables not being set via a shell script. [message #294515 is a reply to message #294502] Thu, 17 January 2008 19:46 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
To source a file, you put a DOT (.) and a SPACE before it on the SH / KSH / BASH command line.

Instead of:
set_vars

do this
. set_vars


Ross Leishman
Re: Env variables not being set via a shell script. [message #294523 is a reply to message #294515] Thu, 17 January 2008 22:21 Go to previous messageGo to next message
shahnazurs
Messages: 240
Registered: June 2005
Location: India
Senior Member
Hi.

When you execute this script, system will open sub shell(ksh) and set your environmental variables.


These environmental variables can`t be used by your login shell.

If you want to set permanently then you need do this in your environmental files.

What is your login shell?

to check your login shell just execute
echo $SHELL


Thanks.
Re: Env variables not being set via a shell script. [message #294557 is a reply to message #294523] Fri, 18 January 2008 00:18 Go to previous message
vjeedigunta
Messages: 201
Registered: March 2005
Location: Hyderabad
Senior Member

Thanks all for your replies.. i figured this out .. I tried executing this with . file.sh and it worked fine ..

Thanks....
Previous Topic: Anxious, oracle small machine on increases when the bare equipment makes a mistake, asks the master
Next Topic: How to redirect mail sent to root to external mailbox? (merged)
Goto Forum:
  


Current Time: Thu Apr 18 12:37:57 CDT 2024