How to list files on ftps

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

adea
Posts: 9
Joined: Mon Aug 12, 2019 7:44 am

How to list files on ftps

Post by adea » Mon Aug 12, 2019 8:17 am

Hi,
I'm using the ftp command below (with slash at the end) to list the files and folders on our ftp. Please note, there's spaces between the command because email or url links can't be posted.

Code: Select all

put URL "ftp://username:password@ourftp .ourftpserver. com/folder/" into tData 
Now, our ftp was recently upgraded to ftps using implit on port 990. When I use the command below, the result is empty.

Code: Select all

put URL "ftps://username:password@ourftps .ourftpsserver. com:990/folder/" into tData 
Could you kindly help on how to get the directory list (for ftps using implit on port 990)?

Thank you.

bogs
Posts: 3994
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to list files on ftps

Post by bogs » Mon Aug 12, 2019 12:03 pm

The first thing I found when looking at your question was this answer from a couple of years ago...
https://forums.livecode.com/viewtopic.php?t=23479

Depending on the version of Lc your using, though, this may also be a possible solution...
https://livecode.fandom.com/wiki/TsNet

Since I don't do much with ftp, though, I can't say for sure.
Image

adea
Posts: 9
Joined: Mon Aug 12, 2019 7:44 am

Re: How to list files on ftps

Post by adea » Mon Aug 12, 2019 3:08 pm

Thanks bogs for your reply.

From the examples you've listed, the command tsNetGet was used to get the directory list. There's a setting "use_ssl" for FTPS explicit connection. However, ours is FTPS implicit connection. Nonetheless, I tried it but it failed, see code below. How can we set it to implicit connection? I listed below all the setting available for tsNetGet.

Code: Select all

-- Enable TLS for explicit FTPS
put true into tSettings["use_ssl"]
put "ftps://username:password@ourftps .ourftpsserver. com:990/folder/" into ftpfolder
put tsNetGet("1", ftpfolder, "", "transferComplete", tSettings) into tResult
The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type):

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

"username": Set to a string containing the username to be used in any authentication requests from the server.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

bogs
Posts: 3994
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to list files on ftps

Post by bogs » Mon Aug 12, 2019 3:17 pm

Hopefully someone will chime in with a better answer for you, as I said, I myself do very little with ftp of any kind.
Image

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7018
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to list files on ftps

Post by FourthWorld » Mon Aug 12, 2019 8:50 pm

Why FTP specifically?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

adea
Posts: 9
Joined: Mon Aug 12, 2019 7:44 am

Re: How to list files on ftps

Post by adea » Tue Aug 13, 2019 8:21 am

Our IT dept decided to secure our ftp server with ftps with implicit connection on port 990.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7018
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to list files on ftps

Post by FourthWorld » Tue Aug 13, 2019 4:11 pm

adea wrote:
Tue Aug 13, 2019 8:21 am
Our IT dept decided to secure our ftp server with ftps with implicit connection on port 990.
Yes, I caught the "s" part. My question wasn't clear:

What is the role of the server that it benefits more from a protocol designed for ad hoc file access as opposed to something more controlled like HTTP?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

adea
Posts: 9
Joined: Mon Aug 12, 2019 7:44 am

Re: How to list files on ftps

Post by adea » Wed Aug 14, 2019 9:34 am

Sorry, I'm not able to answer your question.

Going back to my inquiry - how to get the directory list on ftps with implicit connection on port 990. Based on the example, the setting for tsNetGet is "use_ssl", to Enable TLS for explicit FTPS. How about for implicit FTPS, what is command?

Thank you.

Klaus
Posts: 11309
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to list files on ftps

Post by Klaus » Wed Aug 14, 2019 11:57 am

Hi adea,

did you try the LIST FTP command? Should be something like:

Code: Select all

...
put "LIST" into tCmds
put "ftps://username:password@ourftps .ourftpsserver. com:990/folder/" into ftpfolder
put tsNetSendCmd("1", ftpfolder, tCmds, "transferComplete") into tResult
...

Code: Select all

on transferComplete pID, pResult, pBytes, pCurlCode
   local tData, tHeaders
   if pCurlCode is not 0 then
      answer tsNetRetrError(pID)
   end if
   put tsNetRetrData(pID, tError) into tData
   tsNetCloseConn pID
   answer "Server response:" & tData
end transferComplete
However I am not sure every FTP server understandss this command, depends on the setup.


Best

Klaus

adea
Posts: 9
Joined: Mon Aug 12, 2019 7:44 am

Re: How to list files on ftps

Post by adea » Wed Aug 14, 2019 2:53 pm

Thanks Klaus for the code.

When I tested it, unfortunately, the result shows "tsneterr: Only ftp:// and sftp:// URLs allowed for tsNetSendCmd"

And ours is ftps://...

Klaus
Posts: 11309
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to list files on ftps

Post by Klaus » Wed Aug 14, 2019 3:08 pm

Oops, sorry, did not even notice the difference... :oops:

adea
Posts: 9
Joined: Mon Aug 12, 2019 7:44 am

Re: How to list files on ftps

Post by adea » Wed Aug 14, 2019 3:21 pm

Hi Klaus,

In the documentation of tsNetSendCmd, it support ftps but why there's an error.

I'm using LiveCode Indy 9-0-4

Thanks.

Klaus
Posts: 11309
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to list files on ftps

Post by Klaus » Wed Aug 14, 2019 4:00 pm

May be a documentation error...

adea
Posts: 9
Joined: Mon Aug 12, 2019 7:44 am

Re: How to list files on ftps

Post by adea » Mon Aug 19, 2019 1:42 pm

Hi Klaus,

From our IT dept, we can now use ftp, so when i sent the command:

Code: Select all

put tsNetSendCmd("1", ftpfolder, tCmds, "transferComplete") into tResult
the tResult is: "tsneterr: (28) server response timeout"

It's timeout maybe because we need to set implicit connection? How? Thank you.

Regards,

Maynard

adea
Posts: 9
Joined: Mon Aug 12, 2019 7:44 am

Re: How to list files on ftps

Post by adea » Mon Aug 19, 2019 3:44 pm

I tested both true and false at "use_ssl" setting, however, both tResult is: "tsneterr: (28) server response timeout".

Code: Select all

put true into tSettings["use_ssl"]
put "NLST" into tCmds
put tsNetSendCmdSync(ftpfolder, tCmds, tResultCode, tBytes, tSettings) into tResult

Code: Select all

put false into tSettings["use_ssl"]
put "NLST" into tCmds
put tsNetSendCmdSync(ftpfolder, tCmds, tResultCode, tBytes, tSettings) into tResult
"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

Post Reply

Return to “Internet”