Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl -u login:pass ftp.myftpsite.com/iiumlabs* -O
- curl -u login:pass ftp.myftpsite.com/iiumlabs* -O
- open ftp.myftpsite.com
- login
- pass
- mget *
- quit
- ftp -i -s:yourscript
- pscp -batch login@mysshsite.com:iiumlabs* .
- wget --no-verbose --no-parent --recursive --level=1
- --no-directories --user=login --password=pass ftp://ftp.myftpsite.com/
- for /f %%f in ('curl -s -l -u user:pass ftp://ftp.myftpsite.com/') do curl -O -u user:pass ftp://ftp.myftpsite.com/%%f
- setlocal EnableDelayedExpansion
- cd wheretodownload
- set STR=
- for /f "skip=2 delims=" %%F in ('P:curl -l -u user:password ftp://ftp.example.com/directory/anotherone/') do set STR=-O "ftp://ftp.example.com/directory/anotherone/%%F" !STR!
- pathtocurl.exe -v -u user:password !STR!
- $host = "ftp://example.com/dir/";
- $savePath = "downloadedFiles";
- if($check = isFtpUp($host)){
- echo $ip." -is alive<br />";
- $check = trim($check);
- $files = explode("n",$check);
- foreach($files as $n=>$file){
- $file = trim($file);
- if($file !== "." || $file !== ".."){
- if(!saveFtpFile($file, $host.$file, $savePath)){
- // downloading failed. possible reason: $file is a folder name.
- // echo "Error downloading file.<br />";
- }else{
- echo "File: ".$file." - saved!<br />";
- }
- }else{
- // do nothing
- }
- }
- }else{
- echo $ip." - is down.<br />";
- }
- function isFtpUp($host){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $host);
- curl_setopt($ch, CURLOPT_USERPWD, "anonymous:your@email.com");
- curl_setopt($ch, CURLOPT_FTPLISTONLY, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 3);
- $result = curl_exec($ch);
- return $result;
- }
- function saveFtpFile( $targetFile = null, $sourceFile = null, $savePath){
- // function settings
- set_time_limit(60);
- $timeout = 60;
- $ftpuser = "anonymous";
- $ftppassword = "your@email.com";
- $savePath = "downloadedFiles"; // should exist!
- $curl = curl_init();
- $file = @fopen ($savePath.'/'.$targetFile, 'w');
- if(!$file){
- return false;
- }
- curl_setopt($curl, CURLOPT_URL, $sourceFile);
- curl_setopt($curl, CURLOPT_USERPWD, $ftpuser.':'.$ftppassword);
- // curl settings
- // curl_setopt($curl, CURLOPT_FAILONERROR, 1);
- // curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
- curl_setopt($curl, CURLOPT_FILE, $file);
- $result = curl_exec($curl);
- if(!$result){
- return false;
- }
- curl_close($curl);
- fclose($file);
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement