Subject Re: ftp function
From Mervyn Bick <invalid@invalid.invalid>
Date Wed, 27 Mar 2024 10:48:06 +0200
Newsgroups dbase.getting-started

On 2024/03/27 00:24, Michael wrote:
> Hi Guys,
> Is there a fnction available or is there a way I can log into an ftp server and go to a particular folder once logged on?

Back in 2013 I was experimented with the DOS FTP command with some
success. was a file in the dUFLP but this has since
disappeared.  Since then more and more servers are requiring SFTP or
FTPS which are not handled by the DOS FTP command which is probably why was removed.

    set procedure to
    t = new clFTP()
    t.user = "anonymous"
    t.password = ""
    t.remotedir = "/pub/"
    t.mode = "ASCII"
    t.localdir = "c:\duflp\examples\test"
    close procedure

An alternative, using a script, didn't need the .cc.

set procedure to :duflp:miscapi.prg
runhidden("ftp  -s:test.script >> testftp.log")

The script is as follows.  The first two entries are replies to the
prompts User: and Password:

anonymous  //email address is required as password
lcd d:\examples\test
cd /pub/
get all-wcprops

I've just run this and the log is

Connected to
220-Welcome to the HEAnet mirror site,
220- NOTE: All connections and transfers are logged; if this is
220- please disconnect now.
220- * is located in Dublin, Ireland and operated by
HEAnet, the
220-   Irish National Research and Education Network.
220- * This is a two node cluster with 1 Gigabit access to the HEAnet
220- * Please contact with any operational queries.
220- * You are connected to ftp-node1
220 FTP server on
200 UTF8 set to on
User (
331 Anonymous login ok, send your complete email address as your password

230 Anonymous access granted, restrictions apply
ftp> ASCII
200 Type set to A
ftp> lcd d:\examples\test
Local directory now D:\examples\Test.
ftp> cd /pub/
550 /pub/ No such file or directory

ftp> ls
200 PORT command successful
425 Unable to build data connection: Permission denied
ftp> get all-wcprops
200 PORT command successful
550 all-wcprops: No such file or directory

ftp> disconnect
221 Goodbye.
ftp> quit
**************** will still allow a "plain vanilla ftp" login but requires
either SFTP or FTPS (I'm not sure now which one but probably FTPS) for
data transfer which is why the ls (abbreviated list files) failed.  Over
the years the folder structure has obviously been changed which would
account for not being able to change directories.

If your FTP server will accept plain FTP for sending and receiving data
then this approach should work.  If not, you will need 3rd-party software.