Re: Environment variables ignored in shells forked within a su shell

From: Bill Verzal (Bill_Verzal@BCBSIL.COM)
Date: Tue Feb 25 2003 - 17:36:35 EST


su user
run script, second first line after #!/bin/ksh is ".
<scripttosetenvironment>", where "<scripttosetenvironment>" is your
alternate script.

Variables should be exported.

BV
--------------------------------------------------------------------------------------------------------
Bill Verzal
Technical Consultant
Forbes Technical Consulting
(312) 653-3684
bill_verzal@bcbsil.com
billverzal@imcingular.com (Pager)
888-428-4025 (Pager)
MailStop: 27.202B

"Fernandez Garay Jorge" <ferjor@COTO.COM.AR>
Sent by: "IBM AIX Discussion List" <aix-l@Princeton.EDU>
02/25/2003 04:56 PM
Please respond to "IBM AIX Discussion List"

        To: aix-l@Princeton.EDU
        cc:
        Subject: Environment variables ignored in shells forked within a su shell

Within a sh program (is an automated process), I need to su from root
to a user whose .profile is exessively customized for interactive
sessions,
while the automated process runs in the background.

I've tried to avoid this .profile, creating a 'clean', alternate file,
containing
only the indispensable environment needed for the execution of the auto-
mated process.

Next, from this process, I've su'ed to user in the following way:

Having root credentials
su user "-c . alternate_profile; trigger_process". (Note: I'm not
reading
        user's profile)

Where alternate_profile is a file containing environment variables, all of
them exported. Note this file is read, then every line in it, executed,
as
a real .profile.

trigger_process is a process that correct some undesired conditions in
the user's environment, and needs the exported variables to run OK.

Well, problem is that this trigger process can't see the exported envi-
ronment. Within the shell openned by 'su', variables are set.
trigger_process runs in a new shell, and it happened as if all the
exported
environment gets deactivated within the new shell

Has anyone in the list some idea to resolve this problem??
Any help will be appreciated. Thanks in advance.

Jorge

        Ing. Jorge A. Fernandez Garay
                 Administrador UNIX
Jefatura de Tecnologia y Comunicaciones
                    Gerencia de Sistemas

                                             COTO CICSA

**********
The information contained in this communication is confidential, private, proprietary, or otherwise privileged and is intended only for the use of the addressee. Unauthorized use, disclosure, distribution or copying is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender immediately at (312)653-6000 in Illinois; (972)766-6900 in Texas; or (800)835-8699 in New Mexico.
**********



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 22:16:37 EDT