in reply to Retrieving evironment variables from a shell script

You could just execute that script, if you can trust it's contents.
`/path/to/script`;
Note: those are back"ticks"

or
system('/path/to/script');
Update:
This won't work, see Fastolfe's post. Sorry.

Replies are listed 'Best First'.
RE: RE: Retrieving evironment variables from a shell script
by Fastolfe (Vicar) on Aug 02, 2000 at 00:52 UTC
    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.

      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.

RE: RE: Retrieving evironment variables from a shell script
by markguy (Scribe) on Aug 02, 2000 at 00:59 UTC
    I did indeed try both of those... oddly, neither worked. (btw, I believe you mean to point out that there are backticks, not backslashes in the first line... I knew what you meant ;)

    I think there's some sort of issue with the fact that when the shell script is invoked, it forks, so that by the time the perl script picks back up, the %ENV is back to being blank. But I could be full of it, as this isn't my area of expertise...

    Thanks anyway for the help... it's good to know that I wasn't way off when I tried that myself :)
    markguy