簡體   English   中英

PHP exec命令在Windows上不起作用,在命令行上工作

[英]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");

對我來說,解決方案是

在終端窗口而不是服務中運行apache。

看到這個線程: apache service php exec not work

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM