Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php wget inside exec不会生成任何输出或保存网页_Php_Exec_Wget - Fatal编程技术网

Php wget inside exec不会生成任何输出或保存网页

Php wget inside exec不会生成任何输出或保存网页,php,exec,wget,Php,Exec,Wget,我正在做一个小型的个人项目,可以用PHP和wget将整个网页保存到本地磁盘上 基本上,当我传递URL时,它应该保存网页,通过以下方式修复URL和图像: exec('cd application/collection; wget -k -p --user-agent=Firefox/11.0 google.com, $output', $return); print_r($output); // Array( ) print_r($return); // 0 奇怪的是,我没有得到任何输出,目录

我正在做一个小型的个人项目,可以用PHP和wget将整个网页保存到本地磁盘上

基本上,当我传递URL时,它应该保存网页,通过以下方式修复URL和图像:

exec('cd application/collection; wget -k -p --user-agent=Firefox/11.0 google.com, $output', $return);

print_r($output); // Array( )
print_r($return); // 0
奇怪的是,我没有得到任何输出,目录中没有保存任何内容。我可以确认,这是正确的目录。我的本地主机正在运行用户www,如何允许通过PHP的exec函数使用wget保存网页

我无法使用file\u get\u内容,因为它无法修复URL和图像。

请尝试使用以下内容:


行政cd申请/收集/usr/bin/wget-k-p-user-agent=Firefox/11.0http://www.google.com“,$output,$return

你可能已经解决了这个问题,但谷歌将我重定向到这个问题,所以,对于其他人:

您需要将stderr重定向到stdout:2>&1

exec('cd application/collection; wget -k -p --user-agent=Firefox/11.0
google.com 2>&1', $output, $return);
print_r($output); 
print_r($return); 

您是否在两台不同的服务器上尝试此操作?wget在两个路径上都是吗?我没有得到任何输出,但返回值现在是127。它在我的环境中正常工作。尝试使用绝对路径。我是这样做的,两个都没有任何效果。