setenv LD_LIBRARY_PATH for Matlab in PHP page

I have tried to run a external program on a PHP page, the program requires matlab. I have been struggle to set up the enviromental variables for Matlab.

When I run on UNIX command line:
      setenv LD_LIBRARY_PATH /usr0/local/lib/v73/runtime/glnx86:/usr0/local/lib/v73/sys/os/glnx86:/usr0/local/lib/v73/sys/java/jre/glnx86/jre1.5.0/lib/i386/native_threads:/usr0/local/lib/v73/sys/java/jre/glnx86/jre1.5.0/lib/i386/client:/usr0/local/lib/v73/sys/java/jre/glnx86/jre1.5.0/lib/i386:/usr0/local/lib/v73/bin/glnx86

it works fine.

Here is what I used  on PHP page:

$setEnv = "LD_LIBRARY_PATH=:/lib:/usr0/local/lib/v73/runtime/glnx86:/usr0/local/lib/v73/sys/os/glnx86:/usr0/local/lib/v73/sys/java/jre/glnx86/jre1.5.0/lib/i386/native_threads:/usr0/local/lib/v73/sys/java/jre/glnx86/jre1.5.0/lib/i386/client:/usr0/local/lib/v73/sys/java/jre/glnx86/jre1.5.0/lib/i386:/usr0/local/lib/v73/bin/glnx86 ; export LD_LIBRARY_PATH" . "XAPPLRESDIR=/usr0/local/lib/v73/X11/app-defaults; export XAPPLRESDIR; " . "$runProgram";
shell_exec("$setEnv");

it gives me the following errors, seems like the matlab path wasn't right and the program won't run if it can't find matlab lib.
error while loading shared libraries: libmwmclmcrrt.so.7.3: cannot open shared object file: No such file or directory.

Can somebody please help me on this?
yue520Asked:
Who is Participating?
 
TeRReFConnect With a Mentor Commented:
You could try putenv()
http://php.net/putenv
0
 
TeRReFCommented:
I could be a permission issue. Does the user PHP runs under (i.e. apache user if you run your script from webserver) have permissions to access the libraries?
0
 
yue520Author Commented:
-rwxr-xr-x  1 root root  20000 Nov 22  2005 libmwmclmcrrt.so.7.3

Is these permission enough for users? sorry, I am new to PHP.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
TeRReFCommented:
Yep, that should be enough...
0
 
yue520Author Commented:
any other suggestions?
0
 
TeRReFCommented:
Try to use system() to execute the setenv command you use on the command line. It should set the environment for the user the script runs under. Then, you should be able to execute the program...
0
 
yue520Author Commented:
when I use system() with the setenv command from command line, it says:

sh: setenv: command not found
error while loading shared libraries: libmwmclmcrrt.so.7.3: cannot open shared object file: No such file or directory

I wonder why it says it can't find setenv?
0
 
TeRReFCommented:
Because you need to specify the whole path to setenv...

Do a
locate grep | grep bin
to see where it resides and add the path info to the system() call
0
 
yue520Author Commented:
can you be specific? I did locate grep | grep bin, but I am not sure what path you are talking about? or what thing I am trying to locate?

Thanks
0
 
TeRReFCommented:
You will need to find the setenv executable on your system. I'm sorry, I made a mistake. It's:
locate setenv | grep bin

If the listing is very long use this:
locate setenv | grep bin | more

You will have to look for something like:
/usr/bin/setenv or
/usr/local/bin/setenv

Then, use that line in your system() call...


0
 
yue520Author Commented:
Seems like I don't have setenv, I did a locate, nothing was found. Would there be other way to set up enviroment variable in PHP? since this is not my server.
0
 
yue520Author Commented:
That worked. Thanks a million. Hallelujah!
0
 
TeRReFCommented:
Wow :) You're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.