How to set environment variables for a web client?

How to set environment variables for a web client?

Post by Danie » Sun, 24 Dec 2000 15:29:56



I have a compiled cgi program that needs to have the LD_LIBRARY_PATH set
in order to run. But the web client doesn't have this environment
variable set when it runs the cgi. How does one handle this?  I tried
writing a shell script that had a setenv LD_LIBRARY_PATH command
followed by a call to run the cgi program, but that didn't work.
Any ideas?

Thanks,
Daniel

--
To reply to me directly, please remove "ANTISPAM" from the reply-to
email address.

 
 
 

How to set environment variables for a web client?

Post by vkd » Sun, 24 Dec 2000 15:45:19


I assume you have a binary and you can't modify the source?

If you use /sbin/sh, try this:
------------------------------------------
#!/sbin/sh
LD_LIBRARY_PATH=/lib:/usr/local/lib:/whatever
export LD_LIBRARY_PATH
/path-to-cgi-program/program-name
------------------------------------------

You might also try this wrapper:
------------------------------------------
#!/sbin/sh
LD_LIBRARY_PATH=/lib:/usr/local/lib:/whatever
export LD_LIBRARY_PATH
exec /path-to-cgi-program/program-name
------------------------------------------

I don't even think that the export is necessary, but it won't hurt. setenv
only works with csh/tcsh.

However, if this is a perl cgi script and the environment doesn't have
LD_LIBRARY_PATH, you could also try this:

p.138 "Programming Perl" 2nd edition

%ENV
The hash containing your current environment. Setting a value in %ENV
changes the environment for child processes:
$ENV{PATH} = "/bin:/usr/bin"

So try setting LD_LIBRARY_PATH

$ENV{LD_LIBRARY_PATH} = "/lib:/usr/local/lib:/whatever"


Quote:> I have a compiled cgi program that needs to have the LD_LIBRARY_PATH set
> in order to run. But the web client doesn't have this environment
> variable set when it runs the cgi. How does one handle this?  I tried
> writing a shell script that had a setenv LD_LIBRARY_PATH command
> followed by a call to run the cgi program, but that didn't work.
> Any ideas?

> Thanks,
> Daniel
> --
> To reply to me directly, please remove "ANTISPAM" from the reply-to
> email address.


 
 
 

How to set environment variables for a web client?

Post by JB Robertso » Tue, 26 Dec 2000 00:26:48


Hi,

Your http server can usually set this variable for you.
If you're using apache or a similar daemon, the SetEnv directive will do.

From the apache doc:

SetEnv directive

Syntax: SetEnv variable value
Context: server config, virtual host
Status: Base
Module: mod_env
Compatibility: SetEnv is only available in Apache 1.1 and later.

Sets an environment variable, which is then passed on to CGI scripts. Example:

    SetEnv SPECIAL_PATH /foo/bin

HTH

jb

 
 
 

1. Setting environment variables in a web client

I have a compiled cgi program that needs to have the LD_LIBRARY_PATH set

in order to run. But the web client doesn't have this environment
variable set when it runs the cgi. How does one handle this?  I tried
writing a shell script that had a setenv LD_LIBRARY_PATH command
followed by a call to run the cgi program, but that didn't work.
Any ideas?

Thanks,
Daniel

--
To reply to me directly, please remove "ANTISPAM" from the reply-to
email address.

2. Knode Knode

3. Environment variables and web servers

4. Veritas question: vxinstall not recognizing controllers

5. Apache web server environment variables

6. Start Xfilemanager ?

7. Solaris 2.4, PERL, Environment Variables and Web servers

8. Solaris x86 & ISA & 32 MB RAM?

9. How to add new environment variable to web server

10. Setting variables in a variable array of null variables

11. Setting environment variables (netscape enterprise server/aix)

12. Setting Shell Environment Variables from Within C Programs

13. Dynamically setting environment variables on apache startup?