[英]Php exec command not working on Windows, works on 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
它不会产生任何输出。 但是,如果我直接在命令行上粘贴命令,那么它将起作用...
注意:直接在命令行上运行会花费一些时间。
我建议在这里使用shell_exec而不是exec函数。 shell_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转义了反斜杠,因此到达外壳的命令是... 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");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.