2

I want to execute my python script (/var/www/html/start.py) in my php script (/var/www/html/index.php) with the code below:

<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Test</title>
</head>

<body>

<h1>Test</h1>

    <?php
    shell_exec("python /var/www/html/start.py");
    ?>

</body>
</html>

The command works in the terminal and the python code is fine. I also tried to put the code in an external php script. No errors are shown.

#! /usr/bin/env python
import subprocess

subprocess.call(["/home/pi/pipresents/pipresents.py", "-p", "pp_mediashow"])

I am working with an raspberry pi and apache2 to show the index.php on web. I installed PHP 7.3.

1 Answers1

0

Create in sudoers premissions for www-data user and allow run python for that user.

https://serverfault.com/questions/482502/how-to-set-up-sudo-rights-for-execution-of-python-script-from-php

And getting output and exit status from shell_exec()

Nonameix
  • 11
  • 1