Advertisement
Guest User

Untitled

a guest
Aug 14th, 2017
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. curl -u login:pass ftp.myftpsite.com/iiumlabs* -O
  2.  
  3. curl -u login:pass ftp.myftpsite.com/iiumlabs* -O
  4.  
  5. open ftp.myftpsite.com
  6. login
  7. pass
  8. mget *
  9. quit
  10.  
  11. ftp -i -s:yourscript
  12.  
  13. pscp -batch login@mysshsite.com:iiumlabs* .
  14.  
  15. wget --no-verbose --no-parent --recursive --level=1
  16. --no-directories --user=login --password=pass ftp://ftp.myftpsite.com/
  17.  
  18. 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
  19.  
  20. setlocal EnableDelayedExpansion
  21.  
  22. cd wheretodownload
  23.  
  24. set STR=
  25. 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!
  26. pathtocurl.exe -v -u user:password !STR!
  27.  
  28. $host = "ftp://example.com/dir/";
  29. $savePath = "downloadedFiles";
  30. if($check = isFtpUp($host)){
  31.  
  32. echo $ip." -is alive<br />";
  33.  
  34. $check = trim($check);
  35. $files = explode("n",$check);
  36.  
  37. foreach($files as $n=>$file){
  38. $file = trim($file);
  39. if($file !== "." || $file !== ".."){
  40. if(!saveFtpFile($file, $host.$file, $savePath)){
  41. // downloading failed. possible reason: $file is a folder name.
  42. // echo "Error downloading file.<br />";
  43. }else{
  44. echo "File: ".$file." - saved!<br />";
  45. }
  46. }else{
  47. // do nothing
  48. }
  49. }
  50. }else{
  51. echo $ip." - is down.<br />";
  52. }
  53.  
  54. function isFtpUp($host){
  55. $ch = curl_init();
  56.  
  57. curl_setopt($ch, CURLOPT_URL, $host);
  58. curl_setopt($ch, CURLOPT_USERPWD, "anonymous:your@email.com");
  59. curl_setopt($ch, CURLOPT_FTPLISTONLY, 1);
  60. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  61. curl_setopt($ch, CURLOPT_TIMEOUT, 3);
  62.  
  63. $result = curl_exec($ch);
  64.  
  65. return $result;
  66.  
  67. }
  68.  
  69. function saveFtpFile( $targetFile = null, $sourceFile = null, $savePath){
  70.  
  71. // function settings
  72. set_time_limit(60);
  73. $timeout = 60;
  74. $ftpuser = "anonymous";
  75. $ftppassword = "your@email.com";
  76. $savePath = "downloadedFiles"; // should exist!
  77. $curl = curl_init();
  78. $file = @fopen ($savePath.'/'.$targetFile, 'w');
  79.  
  80. if(!$file){
  81. return false;
  82. }
  83.  
  84. curl_setopt($curl, CURLOPT_URL, $sourceFile);
  85. curl_setopt($curl, CURLOPT_USERPWD, $ftpuser.':'.$ftppassword);
  86.  
  87. // curl settings
  88.  
  89. // curl_setopt($curl, CURLOPT_FAILONERROR, 1);
  90. // curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  91. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  92. curl_setopt($curl, CURLOPT_TIMEOUT, $timeout);
  93. curl_setopt($curl, CURLOPT_FILE, $file);
  94.  
  95. $result = curl_exec($curl);
  96.  
  97.  
  98. if(!$result){
  99. return false;
  100. }
  101.  
  102. curl_close($curl);
  103. fclose($file);
  104.  
  105. return $result;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement