Page 1 of 1

How to pass environment variables to cgi executables

Posted: Thu Jun 21, 2007 11:08 am
by xpt
Hi,

Is there any way to pass environment variables to cgi executables?

I want to set up proper LD_LIBRARY_PATH environment variables before
invoking the cgi executables.

Here is my cgi executables, and how I plan to call it.

Code: Select all

$ file omega
 omega: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), not stripped

 <FORM NAME=P METHOD=GET ACTION="omega">
Please help.

FYI. If you need further details, you can check out the background for the request at http://article.gmane.org/gmane.comp.sea ... neral/4704

Thanks

Posted: Thu Jun 21, 2007 12:04 pm
by volka
If you're using an apache server and you want to set this environment variable only for the cgi you might be interested in the SetEnv directive.

Posted: Thu Jun 21, 2007 12:27 pm
by xpt
volka wrote:If you're using an apache server and you want to set this environment variable only for the cgi you might be interested in the SetEnv directive.
thanks for the info.
Environment variables may be passed from the shell which invoked the httpd process.
seems to me that is for how to setup Environment variables for the httpd, ie, whole site and cgis, not a single CGI.

Posted: Thu Jun 21, 2007 3:58 pm
by volka
That you can do with all processes in all shells that support the feature like e.g. bash
http://www.gnu.org/software/bash/manual/bashref.html#SEC51 wrote:The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described in 3.4 Shell Parameters. These assignment statements affect only the environment seen by that command.