Php exec命令在Windows上不工作,在命令行上工作

Php exec命令在Windows上不工作,在命令行上工作,php,command-line,Php,Command Line,我试图通过PHP的exec函数执行以下命令: D:\\pstill -F a4 -2 -c -c -c -c -g -i -t -K -d 700 -a 4 -m XimgAsCMYK -m Xspot -m Xoverprint -o D:\\outputfile.pdf D:\\new.jpg 它不会产生任何输出。但是如果我直接将命令粘贴到命令行上,那么它就可以工作了 注意:直接在命令行上运行时需要一些时间才能完成。我建议在此处使用而不是exec函数。shell\u exec通过适当的

我试图通过PHP的
exec
函数执行以下命令:

D:\\pstill -F a4 -2 -c -c -c -c -g -i -t -K -d 700 -a 4 -m XimgAsCMYK -m Xspot -m Xoverprint -o D:\\outputfile.pdf D:\\new.jpg  
它不会产生任何输出。但是如果我直接将命令粘贴到命令行上,那么它就可以工作了


注意:直接在命令行上运行时需要一些时间才能完成。

我建议在此处使用而不是exec函数。shell\u exec通过适当的shell(WIndows/Unix等)执行命令,并将完整的输出作为字符串返回给您。

我建议在此处使用而不是exec函数。shell\u exec通过适当的shell(WIndows/Unix等)执行命令,并将完整的输出作为字符串返回给您。

如果您的命令是:

exec("pstill -F a4 -2 -c -c -c -c -g -i -t -K -d 700 -a 4 -m XimgAsCMYK -m Xspot -m Xoverprint -o D:\\outputfile.pdf D:\\input.jpg");
PHP逃避反斜杠,因此到达shell的命令是
。。。D:\outputfile.pdf D:\input.jpg
。您必须双重转义反斜杠:一次用于PHP,一次用于shell

exec("pstill -F a4 -2 -c -c -c -c -g -i -t -K -d 700 -a 4 -m XimgAsCMYK -m Xspot -m Xoverprint -o D:\\\\outputfile.pdf D:\\\\input.jpg");

如果您的命令是:

exec("pstill -F a4 -2 -c -c -c -c -g -i -t -K -d 700 -a 4 -m XimgAsCMYK -m Xspot -m Xoverprint -o D:\\outputfile.pdf D:\\input.jpg");
PHP逃避反斜杠,因此到达shell的命令是
。。。D:\outputfile.pdf D:\input.jpg
。您必须双重转义反斜杠:一次用于PHP,一次用于shell

exec("pstill -F a4 -2 -c -c -c -c -g -i -t -K -d 700 -a 4 -m XimgAsCMYK -m Xspot -m Xoverprint -o D:\\\\outputfile.pdf D:\\\\input.jpg");

对我来说,解决办法是

在终端窗口而不是服务中运行apache。

请参阅此线程:
对我来说,解决办法是

在终端窗口而不是服务中运行apache。

请参阅此线程:

您是否收到任何错误消息?请告诉我们您的代码(不仅仅是您正在执行的命令)
exec(“pstill-fa4-2-c-c-c-c-g-i-t-K-d700-a4-mximgascmyk-mxspot-mxoverprint-od:\\outputfile.pdf d:\\input.jpg”)确保Web服务器的用户ID具有执行pstill的适当权限,以及对D:\root目录/驱动器的读/写权限。是否收到任何错误消息?请告诉我们您的代码(不仅仅是您正在执行的命令)
exec(“pstill-fa4-2-c-c-c-c-g-i-t-K-d700-a4-mximgascmyk-mxspot-mxoverprint-od:\\outputfile.pdf d:\\input.jpg”)确保Web服务器的用户ID具有执行pstill的适当权限,以及对D:\root目录/驱动器的读/写权限。