问题
I am trying to call an exe from php. the exe is created from Qt. It runs in Qt as well as from the command line but when I try to run it from php I get incomplete output. The exe takes around 5-7sec to run.
The output that I get from command line is:
--(!)Error loading
--(!)Error loading
1
2
3
4
5
I am not sure what the error loading is for but it stills run the exe and gives the output. But when I run it from php I get
array(2) { [0]=> string(18) "--(!)Error loading" [1]=> string(18) "--(!)Error loading" }
After Error loading it takes abit time in the command line to give the output so may be the php does not wait for it to complete. I am not sure. How can I find out what the error is and how can I solve this? The php script that I am using to call the exe is:
<?php
$addr="/home/ggt/project/build-test-Desktop-Release/test";
exec($addr,$data);
var_dump($data);
?>
I tried using shell_script too. But it does not work. I even inserted a sleep(20) after exec but still its the same.
回答1:
I solved the problem...It was because there was an imshow() in the code which I missed to comment out. So, it did not execute the whole program and stopped it. After I removed the imshow I was able to get all the output.
来源:https://stackoverflow.com/questions/19854746/exe-not-giving-output-in-php