libURLFTPCommand problems

Dave Cragg dave.cragg at lacscentre.co.uk
Fri Jun 4 16:24:52 EDT 2010


On 4 Jun 2010, at 17:42, Jeff Massung wrote:

> I cannot seem to get this to work. Well, to be clear, the function works
> just fine, but none of the commands are working. For example, a simple test:
> 
> put libURLFtpCommand("ls", "my.ftp.site", "username", "password")
> 
> Every time this will put "500 Command not found". However, if I just ftp
> into the account I can do "ls" all day long and it works just fine. I've
> tried DIR, NLST, LIST, caps combinations, etc. PWD works, but almost every
> other command fails.
> 
> Any ideas? Thanks!


You could try "SITE ls" as the command. "ls" isn't a standard ftp command, but many servers support it.

If you just want a directory listing, you can use "get url" with the url to the directory.

Ex:  get url "ftp://myName:myPassword@my.server.com/myDirectory/"

If you do want to use "ls" or "LIST" yourself, you have a bit of work to do.

FTP commands go over a "control connection". Commands that result in "data transfer" (such as STOR, RETR, LIST, NLST) require a separate connection to transfer the data. libURLFtpCommand just sends commands and returns responses over the "control connection". Commands such as PWD only use the "control connection" and so work fine.

To conduct a LIST command fully, the sequence goes something like this:

-- send CWD command to switch to the directory you ned to list
-- send the PASV command to initiate opening a data socket
-- read the response (should be 227) and parse the IP address and port information returned
        typical response looks like this:  227 Entering Passive Mode (173,175,12,250,15,28)
-- open a socket to the IP address and port you've just parsed
-- send the LIST command with the appropriate path data
-- wait for a 150 response (indication that the server is ready)
-- read from the socket you opened previously until it closes

It's not a lot of fun. :-)


Cheers
Dave







More information about the use-livecode mailing list