My goal
is to run my python script using PHP. I have a start button on the front-end when I click on that button. It start a service.
Try #1
$command = escapeshellcmd("python ".public_path().'/python/start_clientsim.py 2>&1');
$result = exec($command);
Still not working
Try #2
$command = escapeshellcmd("python ".public_path().'/python/start_clientsim.py 2>&1');
$result = shell_exec($command);
Still not working
Try #3
chmod a+x start_clientsim.py
-rwxr-xr-x 1 bheng staff 1154 May 17 19:42 start_clientsim.py
Re-tried still same result
Try #4
If I execute the command directly
python /Applications/MAMP/htdocs/code/site/portal/public/python/start_clientsim.py 2>&1
I got it to run perfectly fine.
Try #5
I tried with different python simple script
python /Applications/MAMP/htdocs/code/site/portal/public/python/print.py
print.py
# This program prints Hello, world!
print('Hello, world!')
I got
result: "Hello, world!"
Question
How would one go about and debug this further ?

public_path()? You can try to provide the full path of the python binary, to find it, use,which python. What's the output ofecho "python ".public_path()."/python/start_clientsim.py 2>&1"? does this output runs without errors if pasted on the shell?python /Applications/MAMP/htdocs/code/benu/ssc-portal/public/python/start_clientsim.py 2>&1execis available . It's propably about permissons, like @Marat suggested. Usechmod 0755sudo su <username>) and run the desired command. If it works, then you can either chmod 755, or chown/chgrp service script to the <username>, or add username to the script group - there are many ways to give exec permissions