Issue with the command exec on php

时间:2015-05-12 23:42:50

标签: php xml cmd exec

I've an issue while using exec on php, maybe I didn't understand how it works.

The problem is: I wanna execute a binary file named 'test.exe'. That program takes data from an input file 'input.xml' and create an new file 'output.xml' with some modification on those data.

The below command line works perfectly on windows cmd :

"extension=php_mysli".

But a php script like this :

>cd C:\Test
>test.exe C:\XML\example.xml C:\XML\example.out.xml

Doesn't work like suspected;

Each time I get beside the empty generated file example.out.xml another file named gmon.out.

I don't know what kind of file it is. Is it possible that this file will be the source of my problem?

Any idea?

1 个答案:

答案 0 :(得分:0)

你使用了错误的斜杠,你应该使用一个双反斜杠(一个要打印,另一个要转义它)。使用O(n) = O(log n) 将字面翻译为//,因此PHP会尝试查找//并失败。

更正的语法是

C://Test//test.exe

exec('C:\\Test\\test.exe C:\\XML\\example.xml C:\\XML\\example.out.xml');