I think the only thing you are missing in your PHP script is echo
.
If you call exec("python pytest.py $item");
PHP won't just print the output of the called command.
You need to echo shell_exec("python pytest.py $item");
.
The difference between exec
and shell_exec
is that shell_exec will return the output of the command but exec
won't. You can read more about it here: https://www.php.net/manual/en/function.shell-exec.php and https://www.php.net/manual/en/function.exec.php.
Also make sure the user, which is running the PHP-File, has permissions on the pytest.py file.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…