Operating System - Linux
1748224 Members
4323 Online
108759 Solutions
New Discussion юеВ

scripts loosing the environment

 
Mark McDonald_2
Trusted Contributor

scripts loosing the environment

Hi

We have several boxes mostly(11.11) where the helpdesk users see a menu when they log in.

The main scriptA check the user, exports the variables etc. This calls another scriptB which displays the menu. Script B then calls whichever script is needed depending upon the menu selection.

On a new machine however (11.23) when scriptB calls the final script the last script has lost the variables.

I have an echo at each point in the scripts the variables are set correctly in Script A and Script B, but get lost at the 3rd level

What is happeneing?

Regards

Mark
11 REPLIES 11
Steven Schweda
Honored Contributor

Re: scripts loosing the environment

I have a script which doesn't work. What's
wrong with it?
James R. Ferguson
Acclaimed Contributor

Re: scripts loosing the environment

Hi Mark:

So, was the new machine established with an identical configuration as far as scripts, directories, permissions and ownerships?

Regards!

...JRF...
Mark McDonald_2
Trusted Contributor

Re: scripts loosing the environment

Steven

The script works fine on other machines thanks.... :-/ I was wondering whether something in 11.23 only carries variables down so many new shells are something silly like that.

James

Yes the scripts / directories are the same.

Regards

Mark
Yogeeraj_1
Honored Contributor

Re: scripts loosing the environment

hi,

can you post an extract from your script so that we get a clearer picture?

revert!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
James R. Ferguson
Acclaimed Contributor

Re: scripts loosing the environment

Hi (again) Mark:

> I was wondering whether something in 11.23 only carries variables down so many new shells are something silly like that.

I don't think that this has anything to due intrinsically with 11.11 vs. 11.23, but rather something with configuration.

> Yes the scripts / directories are the same.

Same permissions and ownerships? Same permissions and ownerships of parent directories (all the way up)?

> On a new machine however (11.23) when scriptB calls the final script the last script has lost the variables.

Does scriptB export what the final script will need?

Do you launch the menu script from a '.profile' or do you define it as the shell program in '/etc/passwd'? Is this done the same on all systems?

Lastly, if you a performing any 'su' commands, compare your '/etc/default/security' settings on your servers. In particular, look at settings like 'SU_KEEP_ENV_VARS', 'SU_ROOT_GROUP' and 'SU_DEFAULT_PATH'.

Regards!

...JRF...
Mark McDonald_2
Trusted Contributor

Re: scripts loosing the environment

Hmmm

This is hashed on the box that doesnt work

# Force su to propagate specified unsafe
# environment variables.
# SU_KEEP_ENV_VARS=HOME,SHLIB_PATH

ill have a check around the working boxes.

Thanks
Mark McDonald_2
Trusted Contributor

Re: scripts loosing the environment

The variable in question is MR_LIB_DIR so this would not be stopped by the security file.

the final script is kicked off via sudo though so I think we are along the right lines.
Mark McDonald_2
Trusted Contributor

Re: scripts loosing the environment

also - the script is launched from .profile
Mark McDonald_2
Trusted Contributor

Re: scripts loosing the environment

Found it.....

This line was missing in the sudoers
Defaults env_keep+="*"

Thanks