Solved

setenv LD_LIBRARY_PATH for Matlab in PHP page

Posted on 2006-06-27
13
1,398 Views
Last Modified: 2016-02-10
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?
0
Comment
Question by:yue520
  • 7
  • 6
13 Comments
 
LVL 29

Expert Comment

by:TeRReF
ID: 16994705
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
 

Author Comment

by:yue520
ID: 16994934
-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
 
LVL 29

Expert Comment

by:TeRReF
ID: 16994973
Yep, that should be enough...
0
 

Author Comment

by:yue520
ID: 16994991
any other suggestions?
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 16995064
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
 

Author Comment

by:yue520
ID: 16995167
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Expert Comment

by:TeRReF
ID: 16995221
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
 

Author Comment

by:yue520
ID: 17001374
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
 
LVL 29

Expert Comment

by:TeRReF
ID: 17002098
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
 

Author Comment

by:yue520
ID: 17002503
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
 
LVL 29

Accepted Solution

by:
TeRReF earned 125 total points
ID: 17002571
You could try putenv()
http://php.net/putenv
0
 

Author Comment

by:yue520
ID: 17003408
That worked. Thanks a million. Hallelujah!
0
 
LVL 29

Expert Comment

by:TeRReF
ID: 17003459
Wow :) You're welcome.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now