我正试图通过php exec:执行一个shell脚本
gs -sDEVICE=png16m -dNOPAUSE -dGraphicsAlphaBits=4 -dDOINTERPOLATE -dTextAlphaBits=4 -sOutputFile=%03d.png -r300 ../mydpf.pdf -dFirstPage=2 -dBATCH -quit;
如果我在shell中运行它,它会正常完成,但如果我使用php-exec从web运行它,在处理完16页后它会停止,不会出现错误。这是输出:
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 2 through 44.
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8
Page 9
Page 10
Page 11
Page 12
Page 13
Page 14
Page 15
Page 16
Page 17
在PHP文件中,我有:
ini_set('memory_limit', '1024M');
ini_set('max_execution_time', '18000');
所以这不是内存/执行时间的问题。你能帮帮我吗?可能是什么东西让剧本停了?
非常感谢。
使用shell_exec可以查看返回的内容。
我遇到了同样的问题,这是我的解决方法,希望它能有所帮助:
创建一个bash-shell脚本,在其中使用参数调用gs,然后使用PHP exec()运行sh脚本。