我试图通过PHP运行以下命令:
$output = shell_exec('sudo /Users/Derk/Code/automation/psc/pdfs.sh 1');
这将运行以下bash脚本代码:
sudo /usr/local/bin/pdftk cvcheck_template.pdf fill_form data.fdf output output.pdf flatten sudo /usr/local/bin/convert -density 150 -gravity south -geometry +0+150 -composite output.pdf signature.png new_output.pdf
bash脚本在命令行中完美工作,但是当我尝试通过PHP在Web服务器(MAMP)上运行它时,它不会提供任何输出。 第一个命令似乎可行,但第二个命令却什么也不给我。
任何帮助将非常感激。
最终归结为权限问题。 通过Web浏览器运行Python脚本触及的单个文件需要在www-data组中具有写访问权限。
我的错误是,他们有阅读和执行的权利,但没有写权。 所以一旦我修改了合适的文件,一切都很好用。
我也使用sudo -u www-data commandtestingPHP文件,而不必通过浏览器testing它们。 这使得testing更快。