Local environment overrides for the remote server on the FileOutput node

Set values in the local environment to override the location of the remote server specified on the FileOutput node. You can also use the local environment to specify commands to run before or after FTP or SFTP transfers.

Remote server location

You can set the location of the FTP or SFTP server for the FileOutput node to use in LocalEnvironment.Destination.File.Remote.Server. If this field is present in the local environment, it overrides the Remote server and port property on the FileOutput node. Set this local environment field to the name of a configurable service, the name of a server, or a server name and port number.

The local environment override works in the same way as the node property. If a configurable service exists with the name specified, all the properties of the configurable service are used instead of the properties on the node. If a configurable service of that name does not exist, the value is used as a server name to which the node connects. The system checks for a value with the format serverName:portNumber first, then it searches for a server name on its own. When a server name is found, no other properties are overridden. This process is repeated for every message that passes through the node.
Note: If you are looking for information about local environment overrides for file nodes, go to Using local environment variables with file nodes.

Commands used before or after file transfer

You can also use the local environment to specify commands to run before or after an FTP or SFTP transfer finishes.

The pre-transfer commands are written to the following location in the local environment tree:
LocalEnvironment/Destination/File/Remote/Precommand
This field can be repeated for each pre-transfer command that is required. The commands are run in the index order of the field (for example, Precommand[1] is run before Precommand[2]). If two commands exist under any one Precommand field, an error is issued.
The post-transfer commands are written to the following location in the local environment tree:
LocalEnvironment/Destination/File/Remote/Postcommand
This field can be repeated for each post-transfer command that is required. The commands are run in the index order of the field (for example, Postcommand[1] is run before Postcommand[2]). If two commands exist under any one Precommand field, an error is issued. If the post command fails, the file transfer is not rolled back.
For both pre-transfer and post-transfer commands, you can add the field name IgnoreErrors, and set it to a Boolean value. If the field is set to true, errors generated by the FTP command are ignored (as shown in the following example). If the field is missing, a value of false is assumed, and errors are not ignored. You must add the field to every command for which you want to ignore errors.
LocalEnvironment/Destination/File/Remote/Postcommand[1]/IgnoreErrors = true;
LocalEnvironment/Destination/File/Remote/Postcommand[1]/MKDIR = 'NOTTHERE';
For each command to be run on the server, you can use the values shown in the following tables as fields in the local environment. These commands are not case sensitive.
The following table lists commands that are supported by both FTP and SFTP.
Field name Parameters Usage
RENAME From, To Use this command to rename a file specified in the From field to the file name specified in the To field.
DELETE Value of field Use this command to delete the file specified in the DELETE field.
MKDIR Value of field Use this command to make the directory specified in the MKDIR field.
RMDIR Value of field Use this command to delete the directory specified in the RMDIR field.
CD Value of field Use this command to change the current directory to the directory specified in the CD field.
CDUP No Parameters Use this command to change the current directory to the parent directory.
The following table lists commands that are supported by FTP only.
Field name Parameters Usage
SITE Value of field Use this command to run a SITE FTP command. The value of the SITE field contains the full string to run, including parameters or options.
QUOTE Value of field Use this command to run a raw FTP server command. The value of the QUOTE field is the command, including parameters to run.

This command does not check that the attempted action is compatible with how the transfer works in the file node. Therefore, do not attempt to transfer data, or receive data, by using the quote mechanism; for example, do not use STOR, APPE, or RETR.

The following example shows pre-transfer and post-transfer commands in ESQL.
-- select the remote server
set OutputLocalEnvironment.Destination.File.Remote.Server = 'cs' || cast(I as char);
-- make a new directory on the server
set OutputLocalEnvironment.Destination.File.Remote.Precommand[1].MKDIR = 'T4';
-- change directory into the new directory
set OutputLocalEnvironment.Destination.File.Remote.Precommand[2].CD = 'T4';
-- set the name to which to transfer the file
set OutputLocalEnvironment.Destination.File.Name = 'cs' || cast(I as char);
-- after the transfer, rename the file to a new name in the directory
set OutputLocalEnvironment.Destination.File.Remote.Postcommand[1].RENAME.From = 'cs' || cast(I as char);
set OutputLocalEnvironment.Destination.File.Remote.Postcommand[1].RENAME.To = '../ds' || cast(I as char);
-- change the directory to the parent directory
set OutputLocalEnvironment.Destination.File.Remote.Postcommand[2].CDUP = '';
-- delete the directory that was created previously
set OutputLocalEnvironment.Destination.File.Remote.Postcommand[3].RMDIR = 'T4';
propagate;