I have a script that uses passthru () to run a command. I need to set some shell environment variables before running this command, otherwise it will not be able to find the libraries.
I tried the following:
putenv("LD_LIBRARY_PATH=/path/to/lib"); passthru($cmd);
Using putenv () does not apply to the command I am running. He does not say that he cannot find it in libraries. When I run export LD_LIBRARY_PATH=/path/to/lib
in bash, it works fine.
I also tried the following (in vain):
exec("export LD_LIBRARY_PATH=/path/to/lib"); passthru($cmd);
How to set a shell variable from PHP that extends to the child processes of my PHP script?
I am limited to checking if a variable exists in the current environment and asking the user to manually set it?
source share