Re: scripts loosing the environment (294 Views)
Reply
Trusted Contributor
Mark McDonald_2
Posts: 306
Registered: ‎09-15-2005
Message 1 of 12 (294 Views)

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
Honored Contributor
Steven Schweda
Posts: 9,089
Registered: ‎02-23-2005
Message 2 of 12 (294 Views)

Re: scripts loosing the environment

I have a script which doesn't work. What's
wrong with it?
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 3 of 12 (294 Views)

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...
Trusted Contributor
Mark McDonald_2
Posts: 306
Registered: ‎09-15-2005
Message 4 of 12 (294 Views)

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
Honored Contributor
Yogeeraj_1
Posts: 4,613
Registered: ‎11-25-2001
Message 5 of 12 (294 Views)

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)
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 6 of 12 (294 Views)

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...
Trusted Contributor
Mark McDonald_2
Posts: 306
Registered: ‎09-15-2005
Message 7 of 12 (294 Views)

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
Trusted Contributor
Mark McDonald_2
Posts: 306
Registered: ‎09-15-2005
Message 8 of 12 (294 Views)

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.
Trusted Contributor
Mark McDonald_2
Posts: 306
Registered: ‎09-15-2005
Message 9 of 12 (294 Views)

Re: scripts loosing the environment

also - the script is launched from .profile
Trusted Contributor
Mark McDonald_2
Posts: 306
Registered: ‎09-15-2005
Message 10 of 12 (294 Views)

Re: scripts loosing the environment

Found it.....

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

Thanks
Honored Contributor
Steven Schweda
Posts: 9,089
Registered: ‎02-23-2005
Message 11 of 12 (294 Views)

Re: scripts loosing the environment

> the final script is kicked off via sudo [...]

Doh! Why didn't I realize that immediately?
I'm such a dope sometimes.
Trusted Contributor
Mark McDonald_2
Posts: 306
Registered: ‎09-15-2005
Message 12 of 12 (294 Views)

Re: scripts loosing the environment

-> I'm such a dope sometimes.

You are....
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.