如何使shell_exec在服务器上运行?

时间:2020-07-26 21:18:26

标签: python php shell-exec

因此,我知道网站上有很多类似的问题,但是我找不到任何能够清楚地解释我的问题的答案。希望对此有一个明确的答案可以对其他许多人有所帮助!

我有两个文件,test.php和test.py。

test.php

{
  //snip
  "PublicOrigin": "https://subdomain.domain.com",
  //snip
}

test.py

<?php
  $output = shell_exec('test.py');
  echo $output;
?>

PHP在localhost上打印“ hello,world”,但是在所有空白的服务器(我认为是Unix)上则不打印。我可以使用命令行在服务器上成功运行test.py,并在PHP中检查了function_exists('shell_exec')。

我知道我可能需要授予服务器使用shell_exec的权限,但这使我有些困惑。任何帮助将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:0)

所以我终于解决了这个问题。原来

$ output = exec('python test.py');

完成任务。感谢劳伦斯的指导!

相关问题