Downloading and saving file by using wget in shell

2019-08-05 10:09发布

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

3条回答
Deceive 欺骗
2楼-- · 2019-08-05 10:42

Use cURL. Like this.

查看更多
家丑人穷心不美
3楼-- · 2019-08-05 10:45

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

does the same thing

查看更多
虎瘦雄心在
4楼-- · 2019-08-05 10:54

By default wget write document to file

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

查看更多
登录 后发表回答