dsq2015 2014-11-30 13:38
浏览 120

如何在php中为shell_exec命令设置权限

I need to execute ImageMagick's convert via shell_exec in a php file running apache as localhost on a mac running snow leopard. I have tried all sorts of tips, tricks, edits and permissions garnered from a multitude of questions and solutions from here. But nothing seems to do the trick. The php file below highlights the problem:

<?php
  echo shell_exec('whoami');  //daemon. I chown-ed convert by daemon
  apache_setenv('PATH', '/usr/local/bin:/usr/bin:/bin'); // this works: checked with getenv("PATH");
  echo shell_exec('cp /Users/fullpath/file.pdf  /Users/fullpath/file.pdf 2>&1'); // this works, so shell_exec works
echo shell_exec('/usr/local/bin/convert /Users/fullpath/file.pdf  /Users/fullpath/file.png  2>&1'); // this fails, convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined

?>

I assume this is a permissions problem: but where, on which file?

EDIT: The full error message is:

convert: UnableToCreateTemporaryFile `/Users/fullpath/file.pdf': Permission denied @ error/pdf.c/ReadPDFImage/390.

convert: NoImagesDefined `/Users/fullpath/file.png' @ error/convert.c/ConvertImageCommand/3021.
  • 写回答

1条回答 默认 最新

  • doujingjiao0015 2014-11-30 14:11
    关注

    You are executing convert successfuly, but then the convert itself is returning the error convert: UnableToCreateTemporaryFile and then convert: NoImagesDefined.

    I think this is the answer to the underlying question can be found at https://superuser.com/questions/819277/cant-convert-pdf-into-image-because-of-no-images-defined-error

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料