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 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao
  • ¥20 Vite 打包的 Vue3 组件库,图标无法显示
  • ¥15 php 同步电商平台多个店铺增量订单和订单状态
  • ¥15 关于logstash转发日志时发生的部分内容丢失问题
  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题