Php exec command not working on Windows, works on command line

后端 未结 3 1826
名媛妹妹
名媛妹妹 2021-01-16 13:12

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 -         


        
3条回答
  •  独厮守ぢ
    2021-01-16 13:14

    If your command is this:

    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 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");
    

提交回复
热议问题