# SLES reload system variables on shell script start

**URL:** <https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973>\
**Category:** SLES Configure-Administer\
**Created:** [August 14, 2014, 3:39pm UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973 "2014-08-14T15:39:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbrinkmann](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tbrinkmann](https://forums.suse.com/u/tbrinkmann)\
**Post date:** [August 14, 2014, 3:39pm UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973/1 "2014-08-14T15:39:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![malcolmlewis](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/malcolmlewis/32/11375_2.png) [@malcolmlewis](https://forums.suse.com/u/malcolmlewis)\
**Post date:** [August 14, 2014, 4:11pm UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973/2 "2014-08-14T16:11:10Z")

</div>

> [@](#):
>
> On Thu 14 Aug 2014 12:44:01 PM CDT, tbrinkmann wrote:
> 
> 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;

```auto
.. ~/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!

---

<div class="post-metadata">

**Author:** ![tbrinkmann](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tbrinkmann](https://forums.suse.com/u/tbrinkmann)\
**Post date:** [August 14, 2014, 4:28pm UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973/3 "2014-08-14T16:28:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tbrinkmann](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tbrinkmann](https://forums.suse.com/u/tbrinkmann)\
**Post date:** [August 14, 2014, 5:03pm UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973/4 "2014-08-14T17:03:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![malcolmlewis](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/malcolmlewis/32/11375_2.png) [@malcolmlewis](https://forums.suse.com/u/malcolmlewis)\
**Post date:** [August 14, 2014, 5:28pm UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973/5 "2014-08-14T17:28:42Z")

</div>

> [@](#):
>
> On Thu 14 Aug 2014 01:34:02 PM CDT, tbrinkmann wrote:
> 
> 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

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;

```auto
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!

---

<div class="post-metadata">

**Author:** ![tbrinkmann](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tbrinkmann](https://forums.suse.com/u/tbrinkmann)\
**Post date:** [August 15, 2014, 9:57am UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973/6 "2014-08-15T09:57:43Z")

</div>

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 !

---

<div class="post-metadata">

**Author:** ![malcolmlewis](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/malcolmlewis/32/11375_2.png) [@malcolmlewis](https://forums.suse.com/u/malcolmlewis)\
**Post date:** [August 15, 2014, 4:57pm UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973/7 "2014-08-15T16:57:42Z")

</div>

> [@](#):
>
> On Fri 15 Aug 2014 07:04:02 AM CDT, tbrinkmann wrote:
> 
> 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!

---

<div class="post-metadata">

**Author:** ![tbrinkmann](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tbrinkmann](https://forums.suse.com/u/tbrinkmann)\
**Post date:** [August 15, 2014, 5:16pm UTC](https://forums.suse.com/t/sles-reload-system-variables-on-shell-script-start/25973/8 "2014-08-15T17:16:55Z")

</div>

/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
