How to run from PHP > Python > Matlab > Python > PHP
I'm trying to have PHP run a python script that runs matlab code. I want the matlab output (the value 7.5) to come back to PHP and output to the browser.
When I run my python script from the terminal, it successfully runs the matlab code.
When I run the python script from PHP, it does not output the matlab result to the browser. I should have "7.5" appear in the browser.
If I change the python code to just print something, then I get the correct output in the browser.
I suspect that I'm having an issue with permission, but I've given all of the files RWX permission to all.
<form action='ts.php' method='POST' enctype='multipart/form-data'> <input type='submit' name='matlab_plot' value='Plot in Matlab'> </form>
<?php $command = escapeshellcmd('/Applications/XAMPP/xamppfiles/htdocs/CS85_Project/troubleshoot/ts.py 2>&1'); $output = shell_exec($command); echo $output; ?>
#!/usr/bin/python import matlab.engine eng = matlab.engine.start_matlab() eng.triarea(nargout=0) a = eng.workspace['a'] print a
b = 5; h = 3; a = 0.5*(b.* h);
I have found that the python script stops running at
eng = matlab.engine.start_matlab() when called from PHP. I still don't have a solution to this problem, but my question is: why can't PHP run this python function?