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.  clFTP.cc 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
clFTP.cc was removed.

    set procedure to :duflp:clFTP.cc
    t = new clFTP()
    t.user = "anonymous"
    t.password = "bickmeo@gmail.com"
    t.remotedir = "/pub/www.apache.org/info/.svn"
    t.mode = "ASCII"
    t.localdir = "c:\duflp\examples\test"
    t.FTPgetFile("all-wcprops","ftp.heanet.ie")
    close procedure clFTP.cc

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

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

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

*******
anonymous
bickmeo@gmail.com  //email address is required as password
ASCII
lcd d:\examples\test
cd /pub/www.apache.org/info/.svn
ls
get all-wcprops
disconnect
quit
*******

I've just run this and the log is

**********
Connected to ftp.heanet.ie.
220-
220-Welcome to the HEAnet mirror site, ftp.heanet.ie
(http://ftp.heanet.ie/about)
220------------------------------------------------------------------------------
220-
220- NOTE: All connections and transfers are logged; if this is
disagreeable,
220- please disconnect now.
220-
220- * ftp.heanet.ie is located in Dublin, Ireland and operated by
HEAnet, the
220-   Irish National Research and Education Network.
220-
220- * This is a two node cluster with 1 Gigabit access to the HEAnet
backbone.
220-
220- * Please contact mirrors@heanet.ie with any operational queries.
220-
220- * You are connected to ftp-node1
220-
220------------------------------------------------------------------------------
220-
220 FTP server on ftp.heanet.ie
200 UTF8 set to on
User (ftp.heanet.ie:(none)):
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/www.apache.org/info/.svn
550 /pub/www.apache.org/info/.svn: 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
****************

ftp.heanet.ie 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.

Mervyn.