How to execute php code on website to output matlab license file

I want to display the /Applications/MATLAB_R2014a.app/etc/lmstat on my website, which is running XAMPP on my mac. The path is working on terminal. The result is something like this on terminal:
lmstat - Copyright (c) 1989-2013 Flexera Software LLC. All Rights Reserved.
Flexible License Manager status on
License server status: 25339@school
License file(s) on school: /var/tmp/lm_TMW.dat:
school: license server UP (MASTER) v11.11
Vendor daemon status (on school):
MLM: UP v11.11
So I wrote a php code:
$output = shell_exec('/Applications/MATLAB_R2014a.app/etc/lmstat');
echo "<pre>$output</pre>";
But I got nothing from my website. If I run
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
I can see a list of my web server root folder. Please help ! I am thinking about this might be some file path problem. SO I symbolic a file to /Applications/XAMPP/xamppfiles/htdocs/etc/lmstat but it still does not work.

2 Comments

There is a possibility that the following might work:
$output = shell_exec('/Applications/MATLAB_R2014a.app/etc/maci64/lmutil lmstat');
No promises though.
Not working.... nothing showing up.

Sign in to comment.

Answers (1)

It is most probably because of permission issue. The request from web browser is being instantiated by some other user which doesn't have permission to do what you intend to do (You can confirm this in the error log of XAMPP server xamppfiles/error/error_log). Once you confirm it is a permission issue then do following :
1. Check in XAMPP/xamppfiles/etc/httpd.conf the "user" and group. I am guessing it would be daemon, daemon. I changed it to root, but you can play it with daemon also I guess. Restart your server.
2. Edit sudoers file using visudo to add "daemon ALL=NOPASSWD : ALL". Note change daemon to whatever user you defined in Step 1 above. Please be aware that this might have security issues, I was doing all this on localhost so I didn't bother about such issues (if any).
3. Then run sudo '/Applications/MATLAB_R2014a.app/etc/lmstat' using shell_exec or just exec("sudo /Applications/MATLAB_R2014a.app/etc/lmstat", $out).
This might not be the best solution but it helped me when I got stuck in same type of problem. Let me know if it doesn't work.

Categories

Tags

Asked:

on 14 Nov 2015

Edited:

on 7 Apr 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!