Using tsNet for sftp directory file listing

Charles Warwick charles at techstrategies.com.au
Fri Oct 28 22:52:09 EDT 2016


On 29/10/2016 7:52 AM, Richard Gaskin wrote:
> Skip Kimpel wrote:
>
> > Can anybody guide me in getting a file listing from a remote
> > directory via SFTP connection?  I currently have tsNet functioning
> > to make the connection and uploading / downloading an individual
> > file.  However, I need to retrieve a list of files sitting in a
> > directory.
>
> It's been a while since I've used FTP, but IIRC in previous versions 
> you could just use "get" on a directory and it'll return the file list 
> (note that the trailing "/" is important to let libURL know it's 
> dealing with a directory):
>
>   get url "ftp://name:pass@server/folder/"
>
> Has that changed?
>
Using "get url /path/to/dir/" or "put url /path/to/dir/ into x" works 
with tsNet for both ftp and sftp protocols.

You can also do the same thing using the synchronous or asynchronous 
tsNetGet* functions by specifying the directory with a trailing slash as 
the URL.

As Richard said, the format varies for directory listings if you get a 
"full" listing.  If you are just after the list of filenames, you can 
use "tsNetSetDirNLST true" if using tsNet commands directly, or 
"libUrlSetFtpListCommand 'NLST'" when using libUrl.

Cheers,

Charles





More information about the use-livecode mailing list