Environment variables ignored in shells forked within a su shell

From: Fernandez Garay Jorge (ferjor@COTO.COM.AR)
Date: Tue Feb 25 2003 - 17:26:22 EST


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



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