Scripting commands

Top  Previous  Next

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

 

append

cd

connect

del

deldir

disconnect

exec

get

getdir

lcd

lcopy

ldel

ldeldir

lmove

lrename

mget

mode

mput

msg

prompt

promptmask

put

putdir

rename

set

set debug

set hostname

set lineterm

set logfile

set passive

set password

set protocol

set port

set privatekey

set secure

set timeout

set username

wait

 

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

 

Example

 

Bad

 

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

 

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

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"

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 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 lineterm "<lineterm>"

Specified the line termination to be used when performing ASCII transfers with SFTP/SSH servers that do not support ASCII transfers natively.  FTCL will automatically convert source file, replacing local line terminators with specified line terminator.

 

<lineterm>

 

a valid quoted line terminator.  Valid values include CR (carriage return) and LF (line-feed) or any combination thereof e.g. CRLF.

 

Example

 

set lineterm "LF"

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" and "sftp" for the protocols FTP, FTP over SSL (AUTH SSL), FTP over SSL (Implicit SSL) and SFTP (FTP over SSH) 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

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"

wait <seconds>

Pauses execution of script for specified number of seconds.

 

<seconds>

 

the number of seconds to wait

 

Example

 

wait 5





Home | Company | Products | Solutions | Purchase | Support | Services | Blog

© 2021 JSCAPE LLC