Php exec命令在Windows上不工作,在命令行上工作 [英] Php exec command not working on Windows, works on command line

查看:298
本文介绍了Php exec命令在Windows上不工作,在命令行上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to execute the following command via PHP's exec function:

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  

任何输出。但是如果我直接粘贴命令在命令行然后它工作...

It doesn't generate any output. But if I directly paste the command on the command line then it works...

注意:它需要一点时间完成直接在命令行上运行。 / p>

Note: it takes a bit of time to complete when run directly on command line.

推荐答案

如果您的命令如下:

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。

PHP escapes the backslashes, so the command that reaches the shell is ... D:\outputfile.pdf D:\input.jpg. You have to double-escape the backslashes: once for PHP and once for the 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");

这篇关于Php exec命令在Windows上不工作,在命令行上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆