Home > Backend Development > PHP Tutorial > php中调用popen执行命令行,总返回segmentation fault。但是单独执行命令行就没有问题

php中调用popen执行命令行,总返回segmentation fault。但是单独执行命令行就没有问题

WBOY
Release: 2016-06-23 13:30:19
Original
1406 people have browsed it

代码如下:

$cli = '/path/program getvar 2>&1 ';$handle = popen($cli, 'r');$read = fread($handle, 1024);pclose($handle);
Copy after login

请问是什么原因导致的,我该怎么查问题?


回复讨论(解决方案)

Segmentation fault
记忆体区段错误; 

Segmentation fault
记忆体区段错误; 


哥们,您这不是废话吗?

$handle = popen($cli, 'r');

var_dump($handle); // 看看有什么。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template