从exec()或shell_exec()调用时wget不工作

时间:2016-05-08 16:50:00

标签: php exec wget shell-exec

我正在尝试将我编写的wget命令集成到php脚本中。该命令以递归方式下载网站上的每个html / php文件(这是我在file_get_contents()中找不到的必需功能)。我在终端窗口中测试了wget命令,但是当使用exec()或shell_exec()执行它时没有任何反应。我没有收到任何错误或警告。

这是有问题的命令,

wget --recursive -m --domains oooff.com --page-requisites --html-extension --convert-links -R gif,jpg,pdf http://www.oooff.com/

我尝试过exec()和shell_exec()的简单wget命令(没有那么多参数),但它们也不起作用。

如果wget不是一个选项,我愿意使用其他方法整个下载网站。

我现在的代码是,

exec("wget google.com", $array);

然后在打印数组时它是空的

3 个答案:

答案 0 :(得分:1)

使用适当的选项调用wget

-q to remove it s information output
-O - to output the request response on stdout

php -r 'exec("wget -q -O - google.com", $array);var_dump($array);'

答案 1 :(得分:1)

我必须指定wget的路径。新命令:

exec("/usr/local/bin/wget google.com", $array);

答案 2 :(得分:0)

在我们的案例中,wget没有足够的权限在当前目录中保存wget的文件。解决方案:

$dir = __DIR__.'/777folder/';
exec("/usr/bin/wget -P ".$dir." --other-options");

,其中

-P,  --directory-prefix=PREFIX  save files to PREFIX/...

PS。我们还添加了/usr/bin whereis wget __device__ int sImg; __device__ int *B; /* ############################### INITILIAZE ############################## */ __global__ void initialize(int *tab, int v, int s) { int k = blockDim.x*blockIdx.x + threadIdx.x ; if ( k < s ) tab[k] = v; } /* ########################### The parent kernel ########################### */ __global__ void EDGE(int *A, int *C ,int h, int w, int dim, int nbScales) { sImg = dim*dim; cudaMalloc((void**)&B,sImg*sizeof(int)); int threadsPerBlock = 256; int blocksPerGrid = (sImg + threadsPerBlock -1) / threadsPerBlock; /// I have troubles here, it does not complete the process initialize<<<blocksPerGrid,threadsPerBlock>>>(B,0,sImg); cudaDeviceSynchronize(); initialize<<<blocksPerGrid,threadsPerBlock>>>(C,0,sImg); cudaDeviceSynchronize(); /// A transormation into frequency domain FSDWT <<< 1 , nbScales >>> (A,B, h, w,dim,nbScales); cudaDeviceSynchronize(); /// Tresholding the transform Treshold<<<1,1>>>(B,C,dim*dim); cudaDeviceSynchronize(); cudaFree(B); } /* ############################ call from host ############################ */ extern "C" void EDGE_host(int *A,int *B,int h,int w,int dim, int nbScales) { EDGE <<< 1 , 1 >>> (A,B, h, w,dim,nbScales); } ,但在我们的系统中,没有它可以正常工作

相关问题