Reputation: 58780
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.
$command = escapeshellcmd("python ".public_path().'/python/start_clientsim.py 2>&1');
$result = exec($command);
Still not working
$command = escapeshellcmd("python ".public_path().'/python/start_clientsim.py 2>&1');
$result = shell_exec($command);
Still not working
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
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.
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!"
How would one go about and debug this further ?
Upvotes: 0
Views: 252
Reputation: 124
One way of doing it is to write a PHP module in C that basically acts as a gateway to the python interpreter and then just feed everything through that. This would be much more efficient and is what I would do.
Upvotes: 1