我的情况是,我有一个大约50个帐户的列表,并且在csv中有凭据,如:
cpuser,cppassword,cpdomain,filename-for-download.tgz
HOME
目录(不是public_html
)cpdomain
未激活(NS已更改)SFTP
登录FTP port 21
我尝试使用php脚本,该脚本使用上述凭据,cURL
使用以下文件:
$url = 'ftp://CP.SERVER.IP/filename-for-download.tgz';
$fp = fopen('filename-downloaded.tgz', 'w');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERPWD, "{$cpuser}:{$cppassword}");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_FILE, $fp);
curl_exec($curl);
我得到的是一个0 byte
文件,它确实只由fopen
curl_getinfo()
的回复是:
Array
(
[url] => ftp://CP.SERVER.IP/filename-for-download.tgz
[content_type] =>
[http_code] => 421
[header_size] => 0
[request_size] => 0
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.516362
[namelookup_time] => 0.039582
[connect_time] => 0.276871
[pretransfer_time] => 0
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[certinfo] => Array
(
)
[primary_ip] => REMOTE_SERVER_IP
[primary_port] => 21
[local_ip] => LOCAL_SERVER_IP
[local_port] => 57659
[redirect_url] =>
)
请帮助我理解我做错了什么,以及我应该做些什么。
我还想到移动文件到相应的public_html
然后wget http://CP.SERVER.IP/~cpuser/filename-for-download.tgz
,但是服务器上没有启用此(~username
)访问权限。< / p>