I am using php to have a button refresh a python script. The goal of this is to when a certain input is present and a button is pressed, to run the python script. If there is no user input, there is a default value for $input_val
, just incase. The way I have been trying to test this is in my python file, I have a line that should output to var/tmp/my_logfile.log
, but no logs are being returned when run through the php page. Like every other stack article I've seen it works in the command prompt.
The code I use to try this has been the following:
PHP:
if (isset($_POST['update']))
{
exec('/usr/bin/python3 /var/www/python_test.py ".$input_val."');
}
HTML:
<form name="update" method="post" >
<button name = "update" type="submit"> Update charts </button>
</form>
Some of the references I have used, but to no luck:
Execute Python script from Php
HTML form button to run PHP to execute Python script
https://www.raspberrypi.org/forums/viewtopic.php?t=105932
https://serverfault.com/questions/679198/executing-a-python-script-through-php-button