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.

4
  • check if this post can help you stackoverflow.com/questions/15086572/… Commented Aug 14, 2019 at 7:49
  • No, there no informations which could help me. Commented Aug 14, 2019 at 7:58
  • you do not get any errors? write what the python script does Commented Aug 14, 2019 at 7:59
  • please edit your question with all informations, do not writing in the comment Commented Aug 14, 2019 at 8:02

1 Answer 1

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()

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.