[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Environment



On Thu, Aug 19, 2004 at 03:51:45AM -0400, Mark Richards wrote:
> I have an application that requires a global environment variable be present
> and this same application will be started when the AXIS 82 starts up.
> 
> The code to set the variable is:
> 
> echo "Exporting environment variables"
> HOME=/home
> NCFTPDIR=/var/run
> export HOME NCFTPDIR
> 
> I've put this code directly in the rc script.  The text "Exporting
> environment variables" appears on the system's boot console.  Yet when I
> issue "set" or "env", it does not appear in the initial environment.

In what rc script? Are you running "set" in a subprocess of the 
process that exported the variables?

> 
> /etc/profile works, but only for a login shell.  What I want to see are
> these two environment variables set in the initial environment (and then
> propagate to any shell).

Environment variables can only be exported to sub-processes. I.e. you 
need to set and export them in the parent process of the application.  
That would be the script that starts your application (ncftpd i 
guess).

You ought to export HOME and NCFTPDIR in the rc-script (e.g.  
/etc/init.d/ncftpd) that starts ncftpd (or in a conf-file,
/etc/conf.d/ncftpd and let the rc-script source the conf file, see 
existing rc-scripts for details).

You can see the environment variables of a running process in 
/proc/<pid>/environ.

/Jonas