I am trying to run a simple python script from within my php application.
For test purposes, here is my code:
function run()
{
$result = exec('python3.7 testPy.py',$output, $return_code);
dd($result, $output, $return_code); //dd() is alias for dump and die.
}
run();
testPy.py:
print('Ok')
if I run this command via console as root I get the following output:
root@xxx:Controller$ python3.7 testPy.py
Ok
The same thing is with the www-data user:
www-data@xxx:Controller$ python3.7 testPy.py
Ok
How ever, if call my php script via browser, I get the following output:
run.php on line 3: ""
run.php on line 3: []
run.php on line 3: 2
run.php and testPy.py are in the same folder.
Any ideas are very welcome.
print('Ok')?$result = exec('python3.7 ./testPy.py',$output, $return_code);