cancel
Showing results for 
Search instead for 
Did you mean: 

Enviroment Variables in sh shell

Former Member
0 Kudos

Dear experts,

I currently have a working version of SAP on my server with an Oracle database. In the csh bash shell everything works wonderfully, but during the installation process there is a step where the bash shell has to be changed to sh. My goal is to do the entire process in the sh shell for simplicity. The major issue is that the ORACLE_HOME environment variable is never set automatically when using the sh shell. I have manualy set the variable with the commands ORACLE_HOME=/oracle/<SID>/102_64;export ORACLE_HOME but this is not something that I wish to do every time I want to start SAP. I have tried to mannualy run the .dbenv_<hostname>.sh, which did not solve the problem. Then I wrote my own script just to set the ORACLE_HOME variable, which only sets the variables for when the script is running. What has to be changed so that the environment variables stay after a script in sh runs?

Thanks in advance,

James Anderson

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

At Sunil Bujade

I am getting the environment variables in csh and not sh

I have manually looked at the .dbenv.sh and dbenv.csh

I created the following script with .dbenv lines

ORACLE_HOME=/oralce/<SID>/102_64; export ORACLE_HOME

echo $ORACLE_HOME

This script tells me that ORACLE_HOME is correct when I run the script

After the script is done I use the command echo $ORACLE_HOME and it returns nothing

At Markus Doehr

I am using SuSE 10 64 bit

I am using the proper users ora<sid> and <sid>adm

Thanks for all your help,

James Anderson

markus_doehr2
Active Contributor
0 Kudos

> I am using SuSE 10 64 bit

> I am using the proper users ora<sid> and <sid>adm

Just to get the problem: those two users don't have ORACLE_HOME set when you change the shell to anything else than /bin/sh or /bin/csh?

Markus

Former Member
0 Kudos

in sh there is no ORACLE_HOME

in csh ORACLE_HOME is set correctly

markus_doehr2
Active Contributor
0 Kudos

Do you have a .profile in the home directory?

Markus

Former Member
0 Kudos

I do have a .profile in my <sid>adm user account

Former Member
0 Kudos

Checking for a common misunderstandig:

I have tried to mannualy run the .dbenv_<hostname>.sh, which did not solve the problem.

How have you tried?

Don't do this:

.dbenv_<hostname>.sh

but this:

. .dbenv_<hostname>.sh

Former Member
0 Kudos

well i originally made that mistake but then i figured out that it is a file that has a dot at the beginning.

I have to believe that the problem originates with the fact that i have switched shells.

Thanks for all you help

Former Member
0 Kudos

to clarify my question a little more,

If i use the su command to change from root to ora<sid> in a root log in window the environment variables are not set

and if i just log in as ora<sid> then i do have the environment variables

this happens in the sh shell

in the csh shell i always have my environment vairables

Former Member
0 Kudos

Once again checking for a common misunderstanding:

If i use the su command ...

How?

It's not su orasid, but su - orasid.

Former Member
0 Kudos

so just out of curiosity why does it have to be "su - orasid" to get the environment variables instead of "su orasid"

markus_doehr2
Active Contributor
0 Kudos

> so just out of curiosity why does it have to be "su - orasid" to get the environment variables instead of "su orasid"

man su

Change the effective user id and group id to that of USER.

       -, -l, --login
              make the shell a login shell

su is used to become another user during a login session. Invoked
       without a username, su defaults to becoming the super user. The
       optional argument - may be used to provide an environment similar to
       what the user would expect had the user logged in directly.

Markus

Answers (2)

Answers (2)

markus_doehr2
Active Contributor
0 Kudos

> What has to be changed so that the environment variables stay after a script in sh runs?

What operating system are you using?

And: I never had to set anything manually when working with the proper users, you use different users?

Markus

Former Member
0 Kudos

When you install your SAP and DB, the sapinst will automatically do all the required .sh file settings. Why you want to chnage them? or soemthing went wrong with your variables?

You should be able to set the env in .dbenv.sh or .dbenv.csh (make sure you take a backup before try to chnage)

Former Member
0 Kudos

I have not changed anything in the db files. But when i switched from the csh shell to the sh shell the ORACLE_HOME variable was no longer set when I logged in. The steps i provided before is part of my troubleshooting process.

My guess is that for some reason in the sh shell that the environment variables are not staying set after the script has finished for some reason.

Former Member
0 Kudos

Are you getting the env variable in sh and not in csh?

Check the .dbenv.sh and dbenv.csh and check whether the ORACLE_HOME variable is set in these files.