shell命令用php exec中止,但直接在shell中运行(没有内存问题)

问题描述 投票:0回答:2

我正在尝试通过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');

所以这不是内存/执行时间问题。你可以帮助我 - 它能阻止脚本吗?

非常感谢。

php bash shell exec
2个回答
0
投票

使用shell_exec可以查看返回的内容。


0
投票

我有同样的问题,这是我的解决方法,希望它有所帮助:

创建一个bash shell脚本,在其中使用您的参数调用gs,然后使用PHP exec()运行sh脚本。

© www.soinside.com 2019 - 2024. All rights reserved.