Downloading and saving file by using wget in shell_exec

Deadly 提交于 2019-12-11 07:43:29

问题


I want to download files from commandline when I run the command in shell it will work but when I want to execute it in PHP,No result

$cmd='wget http://cvs.snort.org/viewcvs.cgi/snort/rules/dns.rules'
$output=shell_exec($cmd);
echo "<pre>$output</pre>";

I just wanted to download from this site

any help would be appreciated

how can i correct this?

if the solution is Curl how can I write it


回答1:


Use cURL. Like this.




回答2:


file_get_contents( 'http://cvs.snort.org/viewcvs.cgi/snort/rules/dns.rules' );

does the same thing




回答3:


By default wget write document to file

For prevent default use option: wget -q -O /dev/stdin google.com



来源:https://stackoverflow.com/questions/6649189/downloading-and-saving-file-by-using-wget-in-shell-exec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!