in reply to Access system ENV variables from within CGI Script

Use the technique demonstrated in Get default login environment. Your .profile is only executed when you log in via the shell, not when your CGI program is run, even if it is run under your user account.

Replies are listed 'Best First'.
Re^2: Access system ENV variables from within CGI Script
by Anonymous Monk on Oct 12, 2007 at 11:58 UTC
    Thanks for the link, I am using this code, tillys updated function actually. The shell we are using is ksh. Within the .profile I see many variables which are exported, but sadly do not get printed (using Data::Dumper) when I am testing my script with the tillys function. Any suggestions would be great. TIA

      You will need to debug the output from the `env` command then. Compare what the script outputs when it is run from your shell account. Compare what `env` returns when run from your shell account to the output from the CGI. Take out all intermediaries. Eliminate all differences. Find out where the two scripts/environments differ.

      Most likely, from your .profile something else gets run. Maybe only if there is a terminal connected. It's hard to tell without seeing your code and the relevant parts of the .profile.

        I notice the function calls `echo env |...`, when I do echo env from the command line I get nothing, env by iteself works. An example of a line from the .profile is: TESTUSERS="test@unix.company.com"; export TESTUSERS. This is one of the variables that tillys method does not pick up. Thanks again for your help