File Transfer Script Language

The File Transfer Script Language is a very basic scripting language that allows you to automate routine file transfer processes.  This language may be used when defining a File Transfer Script action as part of trigger.

 

The following commands may be used in a script file when invoking File Transfer Command Line.

 

append "<file>" ["<destination>"]

cd "<directory>"

connect

del "<file>"

deldir "<directory>"

disconnect

exec "<command> "

get "<file>"

getdir "<directory>"

lcd "<directory>"

lcopy "<path>" "<destination>"

ldel"<file>"

ldeldir "<directory>"

lmkdir "<directory>"

lmove "<path>" "<destination>"

lrename "<path>" "<destination>"

mget "<filter>"

mkdir "<directory>"

mode "<mode>"

mput "<filter>"

msg "<message> "

prompt <variablename> "<prompt>"

promptmask <variablename> "<prompt>"

put "<file>" ["<destination>"]

putdir "<directory>"

rename "<path>" "<destination>"

set <variablename> <value>

set aftpcompression <boolean>

set aftpcompressionfilesize <filesize>

set aftpcompressionexclude "<filter>"

set aftpcongestioncontrol <boolean>

set aftpdownloadrate <bitrate>

set aftpsecurity "<mode>"

set aftpuploadrate <bitrate>

set debug <boolean>

set hostname "<hostname>"

set logfile "<file>"

set passive <boolean>

set password "<password>"

set protocol <protocol>

set port <port>

set privatekey "<file>"

set secure <boolean>

set timeout <seconds>

set username "<username>"

set wireencoding "<encoding>"

wait <seconds>

 

The above commands are reserved words in the FTCL language and may not be used as variable names when using the set or prompt commands.

 

Examples

 

Bad example: prompt dir "Enter directory name: "

 

The variable named "dir" may not be used as this is a reserved word for use by the "dir" command used to get a directory listing.

 

Good example: prompt mydir "Enter directory name: "

 

The variable named "mydir" is not a reserved word so may be used.

 

append "<file>" ["<destination>"]

Appends contents of local file to remote file with same name.

 

<file>

 

a quoted relative filename or absolute path

 

<destination>

 

optional quoted remote filename to append to

 

Example

 

append "log.txt" "mylog.txt"

 

Example

 

append "log.txt"

cd "<directory>"

Sets directory on remote server.

 

<directory>

 

a quoted relative directory name or absolute path

 

Example

 

cd "jsmith"

 

Example

 

cd "/home/users/jsmith"

connect

Establishes connection with remote server.

del "<file>"

Deletes remote filename.

 

<file>

 

a quoted relative filename or absolute path

 

Example

 

del "logs.txt"

 

Example

 

del "/home/user/logs.txt"

deldir "<directory>"

Deletes remote directory recursively

 

<directory>

 

a quoted relative directory name or absolute path

 

Example

 

deldir "logs"

 

Example

 

deldir "/home/users/jsmith/logs"

disconnect

Disconnects from remote server.

exec "<command> "

Executes command on local machine.

 

<command>

 

valid command to be interpreted by the local operating system.

 

Example

 

exec "dir c:/tmp > c:/tmp/dirout.txt"

 

See also

 

Escape sequences

get "<file>"

Downloads file from remote server.

 

<file>

 

a quoted relative filename or absolute path

 

Example

 

get "logs.txt"

getdir "<directory>"

Downloads directory recursively from remote server.

 

<directory>

 

a quoted relative directory name or absolute path

 

Example

 

getdir "logs"

 

Example

 

getdir "/var/logs"

lcd "<directory>"

Sets current working directory on local machine. This directory is used when uploading files using relative paths and when downloading files.

 

<directory>

 

a quoted absolute path

 

Example

 

lcd "c:/tmp"

 

See also

 

Escape sequences

lcopy "<path>" "<destination>"

Copies a local file to a local destination.

 

<path>

 

a quoted relative or absolute file or directory path

 

<destination>

 

a quoted relative or absolute file or directory path

 

Example

 

lcopy "logs.txt" "logs.txt.old"

 

Example

 

lcopy "c:/tmp/logs.txt" "c:/tmp/logs.txt.old"

 

See also

 

Escape sequences

ldel"<file>"

Deletes local filename.

 

<file>

 

a quoted relative filename or absolute path

 

Example

 

ldel "logs.txt"

 

Example

 

ldel "c:/tmp/logs.txt"

 

See also

 

Escape sequences

ldeldir "<directory>"

Deletes local directory recursively

 

<directory>

 

a quoted relative directory name or absolute path

 

Example

 

ldeldir "tmp"

 

Example

 

ldeldir "c:/tmp"

 

See also

 

Escape sequences

lmkdir "<directory>"

Creates local directory recursively

 

<directory>

 

a quoted relative directory name or absolute path

 

Example

 

lmkdir "tmp"

 

Example

 

lmkdir "c:/tmp"

 

See also

 

Escape sequences

lmove "<path>" "<destination>"

Moves a local file to a local destination.

 

<path>

 

a quoted relative or absolute file or directory path

 

<destination>

 

a quoted relative or absolute file or directory path

 

Example

 

move "logs.txt" "archive/logs.txt"

 

Example

 

move "c:/tmp/logs.txt" "c:/tmp/archive/logs.txt"

 

See also

 

Escape sequences

lrename "<path>" "<destination>"

Renames file on local machine.

 

<path>

 

a quoted relative or absolute file or directory path

 

<destination>

 

a quoted relative or absolute file or directory path

 

Example

 

lrename "logs.txt" "logs.txt.old"

 

Example

 

lrename "c:/tmp/logs.txt" "c:/tmp/logs.txt.old"

 

See also

 

Escape sequences

mget "<filter>"

Downloads files from current remote directory matching filter.

 

<filter>

 

a quoted regular expression

 

Example

 

mget ".*\\.txt"

mkdir "<directory>"

Creates directory on remote server.

 

<directory>

 

a quoted relative directory name or absolute path

 

Example

 

cd "jsmith"

 

Example

 

cd "/home/users/jsmith"

mode "<mode>"

Sets transfer mode to ASCII or binary.

 

<mode>

 

a quoted transfer mode of "ascii" or "binary"

 

Example

 

mode "ascii"

mput "<filter>"

Uploads local files in current working directory matching filter to remote server.

 

<filter>

 

a quoted regular expression

 

Example

 

mput ".*\\.txt"

msg "<message> "

Sends message to current debugging stream. By default the console is the current debug stream and debugging is enabled.

 

Example

 

msg "connecting to FTP server"

prompt <variablename> "<prompt>"

Prompts user to enter a value to be read from the command line and stores this value in the variable name used in the first argument. The value stored in this variable is then available for use later in the script.

 

Example

 

prompt username "Enter username: "

promptmask <variablename> "<prompt>"

Prompts user to enter a value to be read from the command line and stores this value in the variable name used in the first argument. The value stored in this variable is then available for use later in the script. Value entered is masked to user.

 

Example

 

promptmask password "Enter password: "

put "<file>" ["<destination>"]

Uploads local file to remote server.

 

<file>

 

a quoted relative filename or absolute path

 

<destination>

 

optional quoted remote filename or absolute path to store file as

 

Example

 

put "c:/tmp/logs.txt"

 

Example

 

put "c:/tmp/logs.txt" "mylogs.txt"

 

See also

 

Escape sequences

putdir "<directory>"

Uploads local directory recursively to remote server.

 

<directory>

 

a quoted relative directory name or absolute path

 

Example

 

putdir "logs"

 

Example

 

putdir "c:/tmp/logs"

 

See also

 

Escape sequences

rename "<path>" "<destination>"

Renames file on remote server.

 

<path>

 

a quoted relative or absolute file or directory path

 

<destination>

 

a quoted relative or absolute file or directory path

 

Example

 

rename "logs.txt" "logs.txt.old"

 

Example

 

rename "/var/logs/logs.txt" "/var/logs/logs.txt.old"

set <variablename> <value>

Creates a user defined variable for use within a script.

 

<variablename>

 

A variable name used to reference the variable. Must begin with a letter, and may be followed by 0 or more letters or digits.

 

<value>

 

The value the variable name represents. Valid values include boolean values of true or false, any valid integer or any quoted string.

 

Example

 

set myNumberVariable 12

 

Example

 

set myBooleanVariable true

 

Example

 

set myStringVariable "testing 1.2.3"

 

Variables created may later be referenced using the ${<variablename>} notation.

 

Example

 

set myNumberVariable 12

 

msg "value of myNumberVariable is: {myNumberVariable}"

set aftpcompression <boolean>

Specifies whether streaming compression is enabled or disabled in AFTP connections.  By default compression is enabled.

 

<boolean>

 

true, false

 

Example

 

set aftpcompression false

set aftpcompressionfilesize <filesize>

Specifies the minimum filesize in bytes for compression to be used in AFTP connections. The default minimum filesize is 10485760 (10MB).

 

<filesize>

 

A valid integer between 1-2,147,483,647

 

Example

 

set aftpcompressionfilesize 100000

set aftpcompressionexclude "<filter>"

Specifies a case-insensitive, comma-delimited list of file extensions to exclude when using compression in AFTP connections.  Default value is:

 

".bz2,.F,.gz,.lz,.lzma,.lzo,.rz,.sfark,.xz,.z,.Z,.infl,.7z,.s7z,.ace,.afa,.alz,.apk,.arc,.arj,.ba,.bh,.cab,.cfs,.cpt,.dar,.dd,.dgc,.dmg,.gca,.ha,.hki,.ice,.j,.kgb,.lzh,.lha,.lzx,.pak,.partimg,.paq6,.paq7,.paq8,.pea,.pim,.pit,.qda,.rar,.rk,.sda,.sea,.sen,.sfx,.sit,.sitx,.sqx,.tgz,.tbz2,.tlz,.uc,.uc0,.uc2,.ucn,.ur2,.ue2,.uca,.uha,.wim,.xar,.xp3,.yz1,.zip,.zipx,.zoo,.zz,"

 

<filter>

 

a comma-delimited list of file extensions.

 

Example

 

set aftpcompressionexclude ".zip,.gz"

set aftpcongestioncontrol <boolean>

Specifies whether congestion control is enabled or disabled when connecting using AFTP protocol.  By default congestion control is enabled.

 

<boolean>

 

true, false

 

Example

 

set aftpcongestioncontrol false

set aftpdownloadrate <bitrate>

Specifies the download rate in Kbits per second. The default rate is 45000 Kbps.

 

<bitrate>

 

A valid integer between 1-2,147,483,647

 

Example

 

set aftpdownloadrate 100000

set aftpsecurity "<mode>"

Specifies whether credentials and/or data are protected during an AFTP session.  Default value is "none" providing no protection.

 

<mode>

 

a valid security mode.  Valid values are "none", "credentials & data", "credentials only".

 

Example

 

set aftpsecurity "credentials only"

set aftpuploadrate <bitrate>

Specifies the upload rate in Kbits per second. The default rate is 45000 Kbps.

 

<bitrate>

 

A valid integer between 1-2,147,483,647

 

Example

 

set aftpdownloadrate 100000

set debug <boolean>

Specifies whether debugging is enabled or disabled. By default debugging is enabled and all debugging information is sent to the console.

 

<boolean>

 

true, false

 

Example

 

set debug false

set hostname "<hostname>"

Specified the hostname of the remote server.

 

<hostname>

 

a valid quoted hostname or IP address

 

Example

 

set hostname "192.168.10.2"

set logfile "<file>"

Specifies the path of the log file to write debug data to. By default all output is sent to the console.

 

<file>

 

a valid relative or absolute file path on local machine

 

Example

 

set logfile "c:/tmp/log.txt"

 

See also

 

Escape sequences

set passive <boolean>

Specifies whether passive or active mode should be used in FTP/S protocols.  Default is true.

 

<boolean>

 

true, false

 

Example

 

set passive true

set password "<password>"

Specifies the password to use when logging into the remote server.

 

<password>

 

a valid quoted password for specified username on remote server

 

Example

 

set password "secret"

set protocol <protocol>

Specifies the protocol to use when establishing a connection.

 

<protocol>

 

the protocol to use. Valid options are "ftp", "ftps", "ftps-auth-tls", "ftps-auth-ssl", "ftps-implicit", "sftp" and "aftp" for the protocols FTP, FTP over SSL (AUTH SSL), FTP over SSL (Implicit SSL), SFTP (FTP over SSH) and AFTP respectively. Default protocol is "ftp"

 

Note

 

When using "ftps-implicit" setting you must set the port to the server port responsible for handling implicit SSL connections.  This is typically handled on port 990.

 

Example

 

set protocol "ftps-auth-tls"

 

See also

 

set port (below)

set port <port>

Specifies the port of the remote server. The default ports for FTP and SFTP protocols are 21 and 22 respectively.

 

<port>

 

A valid integer between 1-65535

 

Example

 

set port 2021

set privatekey "<file>"

Specifies the path of private key file to use when authenticating with SFTP server. Valid for use in SFTP protocol only.

 

<file>

 

a valid relative or absolute file path on local machine

 

Example

 

set privatekey "c:/ssh/keys/id_dsa"

set secure <boolean>

Specifies that the secure SFTP protocol be used. FTP protocol is used by default. Requires that SSH version 2.0 or above be installed on remote server and SFTP be enabled.

 

<boolean>

 

true, false

 

Example

 

set secure true

set timeout <seconds>

Sets the maximum timeout used when establishing a connection, sending data or receiving data. If timeout is exceeded script will abort. Default value is 60 seconds.

 

<seconds>

 

the maximum number of seconds to wait

 

Example

 

set timeout 30

set username "<username>"

Specifies the username to use when logging into the remote server.

 

<username>

 

a valid quoted username for remote server

 

Example

 

set username "jsmith"

set wireencoding "<encoding>"

Specifies the wire encoding to use on command channel for FTP/S protocols.

 

<encoding>

 

a valid quoted character encoding

 

Example

 

set wireencoding "UTF-8"

wait <seconds>

Pauses execution of script for specified number of seconds.

 

<seconds>

 

the number of seconds to wait

 

Example

 

wait 5