Custom command configuration properties allow the user to execute custom FTP or SFTP commands immediately before sending or receiving a message, or immediately after sending or receiving a message:
Configuration Property
|
Description
|
---|---|
Before Send Commands | A list of custom commands and associated error handling actions sent to the FTP / FTPS / SFTP server immediately prior to uploading a file. The commands are executed in the directory that will contain the uploaded file, and are executed in the order defined in the configuration. If an error occurs and the error action is not Ignore then the communication point aborts the upload. |
After Send Commands | A list of custom commands and associated error handling actions sent to the FTP / FTPS / SFTP server immediately after uploading a file. The commands are executed in the directory that contains the uploaded file, and are executed in the order defined in the configuration. If an error occurs and the error action is not Ignore then the communication point attempts to delete the uploaded file. |
Before Receive Commands | A list of custom commands and associated error handling actions sent to the FTP / FTPS / SFTP server immediately prior to downloading a file. The commands are executed in the directory that contains the target file, and are executed in the order defined in the configuration. If an error occurs and the error action is not Ignore then the communication point aborts the download. However, if the error action is not Blacklist File then it is likely to attempt to download the same file again shortly afterward. |
After Receive Commands | A list of custom commands and associated error handling actions sent to the FTP / FTPS / SFTP server immediately after downloading a file. The commands are executed in the directory that contains the downloaded file, and are executed in the order defined in the configuration. If an error occurs and the error action is not Ignore then the communication point aborts the download. However, if the error action is not Blacklist File then it is likely to attempt to download the same file again shortly afterward. |
These commands are sent verbatim to the server (with the exception of the variable replacement) and are composed of the following components:
Element | Description |
---|---|
Command | The custom command and its arguments. |
The error action. |
Command
Custom commands are site-specific. Therefore, determining which commands are available requires consulting the appropriate documentation of the FTP / FTPS / SFTP server in use.
SITE Command
FTP has a special SITE
command that is normally used to prefix custom commands supported by the FTP server. If one of these commands is required then the command must be prefixed with SITE
in order for it to be sent correctly. For example, the Apache FTP Server supports a custom command to display user details which would be invoked by configuring a custom command of SITE DESCUSER
. This differs from the obsolete FTP communication point where all custom commands were automatically prefixed with SITE
by the communication point, and so consequently meant that non-SITE
commands could not be executed using this mechanism.
Variable Replacement
There are two special variables that can be contained within custom commands:
%directory%
- replaced with the directory path of the file being uploaded or downloaded.%filename%
- replaced with the name of the file being uploaded or downloaded.
The filename is the actual name of the file being uploaded or downloaded, therefore if temporary files are being used for uploads, this becomes the name of the temporary file.
On Error Action
Custom commands sent to an FTP(S) server are treated as successful if the FTP server returns a code of 1xx, 2xx, or 3xx. The command is considered to have failed if any other type of response is received.
Custom commands sent to an SFTP server are different as the server does not return the same sort of error code. Consequently, custom commands on an SFTP server are treated as failed if the server reports an error to the client while invoking it, or if the command writes to standard error.
For every custom command, you must configure an error handling mode that determines how the communication point should handle errors:
- Ignore - the error is logged but ignored so processing continues normally.
- Treat as Connection Error - the error is treated as a connection error and so the normal connection retry functionality takes effect.
- Send to Error Queue - the outgoing message is sent directly to the Rhapsody error queue. This option is only available for Before Send Commands and After Send Commands.
- Blacklist File - the incoming message is blacklisted (ignored) temporarily as though it failed to download. This option is only available for Before Receive Commands and After Receive Commands. Blacklisting is only temporary and the file is tried again later.
If connection is lost to the FTP / FTPS / SFTP server while executing a custom command, the dropped connection is always treated as a connection error regardless of which option was selected.