开发者

How to get the error from exec?

I am executing a.jar file from PHP through Command Line. However, if there is any error/exception, the error is not bein开发者_如何学Cg displayed. I am using the following PHP script.

<?php
exec('java -jar D:\\ABC\\JavaApplication2\\dist\\JavaApplication2.jar', $result, $returnCode);
var_dump($result);
$count = count($result);
for($i=0; $i<$count;$i++){
    print($result[$i]);
}
?>

The output for the above code is : 'array(0) { }'


don't use exec() if you want to handle I/O, instead use popen() for simple stuff (either read or write) or proc_open() for full fd connectivity, with stdin, stdout, stderr, and possibly other fd's connected (e.g. for openssl).


Probably you need to pipe the output of the jar to some file and listen to that file in PHP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜