FTP, please help...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
roysubs
Posts: 426
Joined: 29 Sep 2018, 16:37

FTP, please help...

10 Nov 2018, 06:36

Could some people give me some working examples of FTP downloads and uploads please? I have been trying this for days and getting nowhere. I've tried various of the ftp libraries that I've seen, not got any working, and for download, of late I thought this was a good lead in using UrlDownloadToFile, but I just keep coming up with *nothing*.

Any example scripts that you know are working would be great, for both FTP download and upload. Ideally using built in API's (which is better / cleaner than building a .scr script and command line ftp or third party tools). Really would appreciate seeing some known working code on this (oh, by the way, I tried to use the AutoHotkey code formatting for the below but for past two weeks that option is not available in the "Select code" pulldown) that would then be easy for me to replace and get working for my situation.

I thought that the following link in the below gave me a way using the UrlDownloadToFile function for the download part but I've been trying variations on this a lot yesterday and getting nowhere (the FTP server works fine for manual access, though the IP address in the below is not real of course):

global ftpserv := "", ftpport := "", ftpuser := "", ftppass := ""
^#f::
ftpserv := "88.110.89.18"
ftpport := "21"
ftpuser := "myname"
ftppass := "mypass"
; Note that you need to encode any special characters. e.g. `%40 instead of @ (percent sign must be escaped if written literally in the script).
; So, only alphanumerics, specials "$-_.+!*'(),", and characters used for their reserved purposes may be used unencoded within a URL.
; https://autohotkey.com/boards/viewtopic.php?t=7320
UrlDownloadToFile, ftp://%ftpuser%:%ftppass%@%ftpserv%:%ftpport%/00.txt, C:\0\11.txt ; to try and download a file from the ftp
UrlDownloadToFile, ftp://myname:[email protected]:800/00.txt, C:\0\11.txt ; to try and download a file from the ftp, without passing variables
UrlDownloadToFile, ftp://myname:[email protected]:800/, C:\0\dir.html ; to try and download an html directory listing, without passing variables
return
list
Posts: 222
Joined: 26 Mar 2014, 14:03
Contact:

Re: FTP, please help...

10 Nov 2018, 09:26

Did you actually try https://github.com/jNizM/AHK_Scripts/bl ... ss_FTP.ahk - it works out of the box, it has the class AND an example at the bottom - example starts below the ====== line with hInternet := FTP.InternetOpen("Upload Test")
roysubs
Posts: 426
Joined: 29 Sep 2018, 16:37

Re: FTP, please help...

10 Nov 2018, 16:26

Thanks list, it works perfectly. I was on there previously, and I had used his other shorter FTP-Download and FTP-Upload scripts under https://github.com/jNizM/AHK_Scripts/tr ... er/src/ftp rather than the class (I guess thinking that these looked a simpler, more direct approach), but I could not get them to work. Using the full class like this works fantastically well and I can get everything working. Thanks very much for this, making a lot of progress now!
roysubs
Posts: 426
Joined: 29 Sep 2018, 16:37

Re: FTP, please help...

16 Nov 2018, 11:57

I've got everything working for my uploads and downloads from ftp with the class as you suggested, works great.

However, I need to download a listing from that FTP server, but I'm stumped. I don't see any methods in the class to do that, and so I searched around and went back to UrlDownloadToFile, which I can ping and can use the class to access via the hostname. I have tried:

UrlDownloadToFile, ftp://wotr:wotr@hp1, C:\0\FTPListing.html
UrlDownloadToFile, ftp://wotr:wotr@hp1/, C:\0\FTPListing.html
UrlDownloadToFile, ftp://wotr:[email protected], C:\0\FTPListing.html
UrlDownloadToFile, ftp://wotr:[email protected]/, C:\0\FTPListing.html

Can you tell me how to get a listing from the FTP? HTML is good, but also just a text file list of the contents of that folder would be great also.
list
Posts: 222
Joined: 26 Mar 2014, 14:03
Contact:

Re: FTP, please help...

17 Nov 2018, 05:07

The FTP class doesn't have that option yet, I opened an issue https://github.com/jNizM/AHK_Scripts/issues/2 - it seems something that could be added without too much trouble for someone like @jNizM

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Billykid, dinodragon, mcd and 150 guests