in reply to RE: Retrieving evironment variables from a shell script
in thread Retrieving evironment variables from a shell script

Note that this won't work.

The script is executed in a child process. Changes to the environment are only accessible to that process. Exported environment variables are accessible to all children processes, but not necessarily the parent. The environment variable changes done by script.sh will be lost as soon as script.sh exits.

The only way to get environment variables in this session is to parse them in as the other poster suggests. The alternative would be to use a shell script or something as your CGI (a wrapper, really), and have it source the conf.sh script first, followed by exec'ing your Perl CGI script.

  • Comment on RE: RE: Retrieving evironment variables from a shell script

Replies are listed 'Best First'.
RE: RE: RE: Retrieving evironment variables from a shell script
by markguy (Scribe) on Aug 02, 2000 at 01:03 UTC
    Thanks for the explanation... I wasn't sure how the script was handled.

    And for the record, I'm going with the parse technique suggested below... appreciate that as well!

    Take care folks...
    markguy

      The whole reasoning behind this behavior, in case you're wondering, is that "environment" variables are supposed to describe the environment that scripts and applications run in. This means that typically they're set at a level higher than the process (e.g. the shell, describing the login/shell session, or the web server, describing this web transaction).

      Items specific to an application or set of applications might better be placed in a configuration file, especially if they're going to be relatively static.