Read from FTP site

Introduction

This channel shows how easy it is to use an FTP (or SFTP or FTPS) server as a data feed for Iguana.

This particular script only processes files ending in “txt” and then deletes those files off the server.
Note: Files are only deleted when the channel is running, not when you are using the Editor.

If you have any questions please contact us at support@interfaceware.com.

Using the Code [top]

  • Import the Read from FTP site channel from the Builtin: Iguana Files repository
  • Experiment with the code to find out how it works
  • Adapt the code to your own requirements
  • You will need to edit the credentials to match a working FTP server

This is the github code for the main module:

How it works [top]

The code is fairly simple:

  1. First we connect to the FTP server using net.ftp.init{}
    Note: You will need to use valid FTP credentials to get the code to work.
  2. Then we get a list of files from the FTP server using the net.ftp.list{} command (C:list{remote_path="."}).
    Note: The dot “.” represent the default path, you can try “/” for the root etc.
  3. Next we use a local function FindFilesThatMatch() to find any matching file names.
  4. Finally we process the matching files by pushing them to the queue and then deleting them.
    Note: You may prefer to move the files to a processed directory rather than deleting them.
  5. We also log the names of the processed files, or the fact that no files were processed, these messages can be viewed in the logs screen:
    Screen Shot 2016-04-15 at 2.32.05 PM

More information [top]

Leave a Reply