Legato
Legato

GoFiler Legato Script Reference

 

Legato v 1.5d

Application v 5.25a

  

 

Chapter TwelveInternet Functions (continued)

12.3 File Transfer Protocol (FTP)

12.3.1 General

Legato provides a layer of FTP functionality that utilizes the underlying Windows WinInet support (used for Internet Explorer as well as many other functions). Additional information is available from Microsoft MSDN. The FTP functionality allows basic file upload, download, directory control and basic file functions. Note that depending on your system’s implementation, FTP is generally not considered a secure interface.

To begin an FTP session, use FTPOpenConnection to create the session object handle. This enables you to perform the following actions on an FTP server:

•  Navigate between directories.

•  Enumerate, create, remove, and rename directories.

•  Rename, upload, download, and delete files.

Connections can be anonymous or via a user ID and password. The connection login will have certain rights assigned by the remote server.

12.3.2 Normal Sequence

The basic sequence is to open a connection, perform functions and then close the connection. For extended functions, it is worth adding connection recovery logic to close and reopen the FTP connection on error.

It is also worth noting that some FTP connections will time out when left idle or if they run for extended periods of time. It is typical that additional TCP/IP ports will be used during an FTP session and the primary port may be idle for too long and the internet route lost. To correct the problem, close and reopen the connection.

12.3.3 Extended Errors

In the event of failure, the GetLastErrorMessage function will retrieve the last message from the remote server. Messages will vary depending on the server. The message is normally a code followed by text:

  Code   Explanation
  100 Series – Requested Action Being Initiated
    110   Restart marker replay.
    120   Service ready in nnn minutes.
    125   Data connection already open; transfer starting.
    150   File status okay; about to open data connection.
  200 Series – Requested Action Successfully Completed
    202   Command not implemented, superfluous at this site.
    211   System status, or system help reply.
    212   Directory status.
    213   File status.
    214   Help message.
    215   NAME system type.
    220   Service ready for new user.
    221   Service closing control connection.
    225   Data connection open; no transfer in progress.
    226   Closing data connection.
    227   Entering Passive Mode
    228   Entering Long Passive Mode
    229   Entering Extended Passive Mode
    230   User logged in, proceed. Logged out if appropriate.
    231   User logged out; service terminated.
    232   Logout command noted, will complete when transfer done.
    250   Requested file action okay, completed.
    257   pathname” created.
  300 Series – Command Accepted (requested action is on hold, pending further information)
    331   User name okay, need password.
    332   Need account for login.
    350   Requested file action pending further information.
  400 Series – Command Not Accepted
    421   Service not available.
    425   Can't open data connection.
    426   Connection closed; transfer aborted.
    430   Invalid username or password
    434   Requested host unavailable.
    450   Requested file action not taken.
    451   Requested action aborted. Local error in processing.
    452   Requested action not taken.
  500 Series – Error
    501   Syntax error in parameters or arguments.
    502   Command not implemented.
    503   Bad sequence of commands.
    504   Command not implemented for that parameter.
    530   Not logged in.
    532   Need account for storing files.
    550   Requested action not taken. File unavailable (e.g., file not found, no access).
    551   Requested action aborted. Page type unknown.
    552   Requested file action aborted. Exceeded storage allocation (for current directory or dataset).
    553   Requested action not taken. File name not allowed.
  600 Series – Confidentiality and Integrity
    631   Integrity protected reply.
    632   Confidentiality and integrity protected reply.
    633   Confidentiality protected reply.

 

12.3.4 FTP Functions

FTP Connection Functions:

CloseHandle — Closes an object handle and releases any associated resources.

FTPOpenConnection — Opens an FTP connection with optional user name, password, port and passive mode flag.

FTP File Functions:

FTPDeleteFile — Deletes a file on a remote server.

FTPGetFile — Downloads a file from the source (remote server) to the destination (local file system).

FTPGetFileSize — Gets the size of a file on the remote server.

FTPGetFirstFile — Gets the first file or folder name in a folder on a remote server.

FTPGetNextFile — Gets the next file or folder name on a remote server.

FTPPutFile — Uploads source file to the server as destination file.

FTPRenameFile — Renames an existing file to a new filename.

FTP Folder Functions:

FTPCreateFolder — Creates a folder on remote server.

FTPDeleteFolder — Deletes a folder on the remote server.

Related Functions:

GetFileAttributeBits — Gets file attributes as a bitwise set of flags from a specified handle or filename.

GetFileAttributeString — Gets file attributes in string form using a filename or handle for a file or an enumeration object.

GetFileCreateTime — Gets file creation time as a file time qword.

GetFileCreateTimeString — Gets file creation time as a string with optional date/time modes.

GetFileModifiedTime — Gets the file modified time as a file time qword.

GetFileModifiedTimeString — Gets file modified time as a string with optional date/time modes.

GetFileSize — Gets the size of a file from a file handle, file enumeration handle, folder, or FTP object.