Question How To Locate And Download A File From Ftp Server?

Osmar Morais

New Member
I´m needing a piece of Openedge code to locate a file on a Windows FTP server and download it in Windows platform. I can do it with Windows Explorer but I´d like to reference it commands like OS-COMMAND or OS-COPY.
Thanks in advance for any help!
 

Cringer

ProgressTalk.com Moderator
Staff member
There is no native way to do what you want to do. You will have to use some third party method which you control via ABL.
 

TheMadDBA

Active Member
Depending on your OE version you can either use the .NET calls to control an FTP client or you can use the command line FTP with scripted input... or you can script input something like cURL.
 

ForEachInvoiceDelete

Active Member
I do something similar.

OS-Command silent "C:\somepath\somefile.bat".

That .bat file contains.

"C:\Program Files\WS_FTP Pro\ftpsync.exe" "C:\somepath\receive.ctl"

the .ctl file is a wsftp config file allowing it to connect to a site and do some tasks, which you can set up within WSFTP.

- ForEach
 

Osmar Morais

New Member
Thanks everybody. I´ve tryied some alternatives and the code below solve my problem.

DEF VAR cDirIN AS CHAR NO-UNDO INIT "c:\temp".

OUTPUT TO value(SESSION:TEMP-DIRECTORY + "Command.ftp").

PUT UNFORMAT "open " + es-instal.host-ftp SKIP.
PUT UNFORMAT es-instal.user-ftp SKIP.
PUT UNFORMAT es-instal.password-ftp SKIP.
PUT UNFORMAT "cd out" SKIP.
PUT UNFORMAT "lcd " + cDirIN SKIP.
PUT UNFORMAT "binary" SKIP.
PUT UNFORMAT "mget *.*" SKIP.
PUT UNFORMAT "y" SKIP.
PUT UNFORMAT "bye".

OUTPUT CLOSE.

OUTPUT TO value(SESSION:TEMP-DIRECTORY + "FTP.bat").

PUT UNFORMATTED "ftp -s:" + SESSION:TEMP-DIRECTORY + "Command.ftp" SKIP
"exit".
OUTPUT CLOSE.

OS-COMMAND SILENT START value(SESSION:TEMP-DIRECTORY + "FTP.bat").
 
Top