Showing posts with label ftp script. Show all posts
Showing posts with label ftp script. Show all posts

Tuesday, June 26, 2007

Kix FTP (Kixtart UDF)

FTP via Kix? Yes!!!

Using Microsoft.XMLHTTP and ADODB.Stream.

Usage:

FTPget("ftp_address", "target_dest_drive", "id", "password")

Code Snippet:

  1. Function FTPget($sURL, $sTargetFile, optional $sUser, optional $sPass)
  2. Dim $oFTP, $oStream $sUser=""+$sUser
  3. $oFTP = CreateObject("Microsoft.XMLHTTP")
  4. if @error
  5. $ftpget=1
  6. exit 1
  7. endif
  8. $oStream = CreateObject("ADODB.Stream")
  9. if @error
  10. $ftpget=2
  11. exit 2
  12. endif
  13. if $sUser
  14. $oFTP.Open("GET", $sURL, not 1, $sUser, $sPass)
  15. else
  16. $oFTP.Open("GET", $sURL, not 1)
  17. endif
  18. if @error
  19. $ftpget=3
  20. exit 3
  21. endif
  22. $oFTP.Send
  23. $oStream.Type = 1
  24. $oStream.Mode = 3
  25. $oStream.open
  26. $oStream.Write($oFTP.responseBody)
  27. if @error
  28. $ftpget=4
  29. exit 4
  30. endif
  31. $oStream.SaveToFile($sTargetFile, 2)
  32. if @error
  33. $ftpget=5
  34. exit 5
  35. endif
  36. $oStream.Close
  37. EndFunction


If at first you fail, call it version 1.0