SLES reload system variables on shell script start

Hi there,

can anyone tell me how to reload or load all system variables without relog ?

background: The new oracle enterprise management agent overwrite all system variables in case of calling shell scripts by job schedule.
So I need to reload the original system variables on start of my shell scripts. The agent login as oracle user and set path to his own AGENT_HOME but I need
to reload the original profile that was set on system start.

Thanks a lot *T

Hi
It depends on what variables are changing, how your logging in, which
shell your using etc. For example I use bash so /etc/bash.bashrc
and /etc/profile are sourced to start, then my ~/.profile and ~/.bashrc

You can create any file you want and the source it via a period in your
script as in;

.. ~/somefile
.. ~/.somefile

If you use the env command to inspect what is changing before and
after, there may only be a few things that change.


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE 13.1 (Bottle) (x86_64) GNOME 3.10.1 Kernel 3.11.10-17-desktop
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

Re,

  1. We use normal bash (SLES11.3).
  2. There is might be misunderstanding.
    The oracle agent overwrite e.g ORACLE_HOME and PATH. So now I can try to reset the PATH in script e.g

export PATH=…

But I think the best way is to reload the on startup environment for the oracle user. Like first in in my shell scripts.

RELOAD standard env,

REALOAD profile.

*T

So I tried to use

source /etc/profile

but the problem is that the systemvar PROFILEREAD: is set to true and the profile than do not set any system var.

→ if test -z “$PROFILEREAD” ; then

trying to unset the var
#>unset PROFILEREAD
-bash: unset: PROFILEREAD: cannot unset: readonly variable

Hi
Running source /etc/profile shouldn’t require you to unset, AFAIK, this
is set read only because other things are called after it eg ~/.bashrc.

So why not just append to the path or in your scripts use the full path
to the things your wanting to run. Or save the current path in your
script eg;

CURRENT_PATH=$PATH
PATH="/sbin:/usr/sbin:/bin"

<your script>

PATH=$CURRENT_PATH


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE 13.1 (Bottle) (x86_64) GNOME 3.10.1 Kernel 3.11.10-17-desktop
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

re,

the problem is that I do not need to append something to path I need to delete something from PATH and many other system vars.

E.g the oracle management agent put his own HOME in front of the PATH.

→ PATH="/u01/app/oracle/product/12/core/12.1.0.4.0/bin:/u01/app/oracle/product/12/core/12.1.0.4.0/jdk/bin:/u01/app/oracle/product/12/core/12.1.0.4.0/perl/bin:/usr/bin:/bin:/usr/local/bin:/home/oracle/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/u01/app/oracle/product/11gR2/db/bin:/bin:/usr/bin:/u01/app/oracle/product/11gR2/db/bin"

Our backup scripts do not work anymore if they are called by the agent. Because the backup tools from oracle now looking into the wrong folders.

I do not want so reset all system variables by hand in my shell scripts. I want to reset the env to the after the start / login normal env.

Thanks a lot !

Hi
Not having worked with oracle, not sure why the additional entries in
the path would create issues with your scripts, or is that because of
the different versions I see 12 and 11gR2? Might be worth a followup
with oracle…?

Anyway, just to clarify, when you first login as your user, all is fine
with the environment variables, then when you run an oracle app it adds
additional bits?

If at login all is good, then you could just add the variables to
your (for example) ~/.profile and then re source it when your wanting to
run your scripts, then I’m assuming when you run the oracle app it adds
it bits back in.

Just to confirm, can you verify the shell eg echo $SHELL


Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
openSUSE 13.1 (Bottle) (x86_64) GNOME 3.10.1 Kernel 3.11.10-17-desktop
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

/bin/bash

I fixed it by resetting all system vars in front of my script by hand. *close

export PATH
export …
export …
export …

Greetings *T