Defining and using variables |
Variables may be defined in FTCL at the command line or in a valid FTCL script file. Once a variable is defined it is then accessible within the FTCL script for use in other commands.
Variables may be defined at the command line using the following syntax:
-<variablename> <value>
Example
java -jar sftp.jar -f scriptfile.txt -filter '*.txt'
In the above example a variable named filter is defined with a value of '*.txt'.
Note
In the above example the value is quoted with single quotes. This is to prevent your operating system shell from performing command line expansion of the regular expression *.txt. Failure to surround regular expressions with single quotes will result in undesired effects.
Defining variables in scripts
You my define variables in scripts using the set command.
Referencing variables in scripts
Variables defined at the command line or in scripts may be referenced using the following syntax:
${<variablename>}
Example
Below is an example of the command issued at the command line and the script contents found in scriptfile.txt.
java -jar sftp.jar -f scriptfile.txt -filter '*.txt'
/** * This example demonstrates connecting to a server, performing a directory * listing and then disconnecting. */
set hostname "ftp.myserver.com" set username "jsmith" set password "secret" connect
// perform directory listing using filter supplied at command line dir "${filter}"
disconnect |