Script command reference

Scripting and shell commands are described in the table below. Abbreviations for commands are noted in the command description.

Where the command has optional arguments, they are shown in square brackets, e.g. open [host[:port]] means that for the open command, the host and port are optional parameters (but if the port is supplied, the host must be supplied).

Command Description
help [command]

Prints out help for a specific command, or if no command is specified, a list of supported commands is provided.

version

Prints out version details.

Can use ver as an abbreviation.

debug

Switches debug on or off. If debug is already on, it is switched off (and vice versa). When debug is enabled, more information is displayed when commands are executed.

set

Sets various parameters used during the session, many of which are optional. Syntax is set name=value

Note that 'set' can be omitted, and thus protocol=ftp is a valid command.

Variables can be created this way. If an unknown variable is set using the 'set' command, then a variable of that name and value is created, e.g. myprotocol=ftp creates a variable called 'myprotocol' set to the string value 'ftp'.

The value of variables can be printed out using echo.

The value of all set variables can be printed out using set without any arguments.

The set command also supports a feature originally found on Unix systems called backquoting. This is where a variable is assigned the value of the output of a command, which must be surrounded by back quotes (the '`' symbol).

For example, to set the variable 'currendir' to the value of the current remote working directory, use set currentdir=`pwd`.

set connectmode

Sets the connection mode for data transfers and listings. Not applicable for SFTP protocol. Possible values are active or passive., e.g. set connectmode=active.

set connectmode

Sets the connection mode for data transfers and listings. Not applicable for SFTP protocol. Possible values are active or passive., e.g. set connectmode=active.

set protocol

Set the protocol to be used. Note that the protocol cannot be changed while connected. Supported protocols are shown below:

Protocol

Description

ftp

"Plain" FTP protocol

ftps

FTPS, i.e. FTP over SSL (explicit mode)

ftpse

FTPS, i.e. FTP over SSL (explicit mode)

ftpsi

FTPS, i.e. FTP over SSL (implicit mode).

sftp

SFTP, i.e. FTP over SSH

Note that server validation is switched off by default.

set connectmode

Sets the connection mode for data transfers and listings. Not applicable for SFTP protocol. Possible values are active or passive., e.g. set connectmode=active.

set remotehost

Sets the remote host to be connected to, e.g. set remotehost=ftp.gnu.org

set user

Sets the username, e.g. set user=javaftp. This username is used for all supported protocols.

set password

Sets the user's password, e.g. set password=javaftp. This password is used for all supported protocols.

set localdir

Sets the local working directory. All uploads and downloads that do not specify a full path will use this directory. e.g. set localdir=D:\work\tmp

set servervalidation

Enables or disables server validation (disabled by default). Possible values are true or false.

set clientcert

Sets the path of the client certificate to use for client validation for FTPS. Currently supports PEM, CER and PFX file formats for certificates. Note that the password must also be set via certpassword.

Once set, client validation is automatically switched on.

set certpassword

Sets the password (or passphrase) of the client certificate used for client validation (FTPS).

set serverpublickey

Sets the path of the server's public key to use for server validation for SFTP. Supports OpenSSH and SECSH file formats.  More typically set knownhosts is used.

Can also use serverkey.

Server validation must also be switched on via set servervalidation=true

set knownhosts

Sets the path of the known_hosts file to use for server validation for SFTP.

Server validation must also be switched on via set servervalidation=true

set clientprivatekey

Sets the path of the client private key file to be used for public key authentication in SFTP. Supports PuTTY, OpenSSH and SSH.com private key formats. Note that the clientprivatekeypass must also be set.

Can also use clientkey.

set clientprivatekeypass

Sets the passphrase of the client private key file to be used for public key authentication in SFTP.

Can also use clientkeypass.

set timeout

Optional. Sets the timeout in seconds for read or write operations. The default is 0 (which is an infinite timeout). e.g. set timeout=10

set port

Optional. Defaults are determined by the protocol. Sets the port number to connect to, e.g. set port=21

set dataports

Optional. Only applicable for active mode. Sets the data port range that the client will listen on for listings and transfers. The low port number must be listed first, e.g. set dataports=10100-10140

set loglevel

Optional. Sets the logging level. 0 means no logging, while 5 is the maximum log level (the default). e.g. set loglevel=4

set logfile

Sets the name or full path of the logfile to direct logging to, e.g. set logfile=C:\temp\ftp.log

echo

Echos the value of a variable to standard output, whether user-defined or a system variable such as 'protocol'. The variable must be preceded by a '$' to identify it as a variable, e.g. echo $protocol.

A synonym for echo is print.

open [host[:port]]

Opens the connection to the remote server. The user and password must already be set via the set command. If the remote host is not already set, it must be supplied here (and will override any previous setting for this connection attempt). The port number can also be optionally supplied (but the host must be provided). e.g. open edtmobile:21

Can also use connect.

binary

Change the current transfer mode to binary mode. Binary is the default.

Can use bin as an abbreviation.

ascii

Change the current transfer mode to ASCII mode. Binary is the default.

Can use asc as an abbreviation.

pwd

Print the current remote working directory.

dir [remotedir]

Perform a detailed listing of the current directory if no directory is supplied as an argument, or of the supplied remote directory.

See ls for a similar command. A synomyn of dir is ls -l.

ls [remotedir]

Perform a simple listing (just filenames) of the current directory if no directory is supplied as an argument, or of the supplied remote directory. If ls -l is used, a detailed listing is supplied.

See dir for a similar command. A synomyn of ls -l is dir.

cd remotedir

Change the current remote working directory to remotedir.

cdup

Change the current remote working directory to its parent directory.

mkdir remotedir

Create the remotedir directory.

rmdir remotedir

Delete the remotedir directory. It must be empty.

get remotefile [localfile]

Download a remotefile to the local host.  The localfile parameter can be a filename or the full path of a local file. If it is a filename, the current local working directory is prepended.

Note that the localfile parameter is optional - if not supplied, the downloaded file is saved in the current local working directory with the name of remotefile.

The remotefile parameter can be a filename or a path. Not all servers support the use of a path - in this case navigate to the correct remote directory using cd.

put localfile [remotefile]

Upload a local file to the remote host. The localfile parameter can be a filename or the full path of a local file. If it is a filename, the current local working directory is prepended.

The remotefile parameter should be a filename or a path. Not all servers support the use of a path - in this case navigate to the correct remote directory using cd.

If the remotefile parameter is not supplied, the local file name will be used.

append localfile [remotefile]

Append the contents of a local file to a remote file (if it exists) on the remote host. The localfile parameter can be a filename or the full path of a local file. If it is a filename, the current local working directory is prepended.

The remotefile parameter should be a filename or a path. Not all servers support the use of a path - in this case navigate to the correct remote directory using cd.

If the remotefile parameter is not supplied, the local file name will be used.

rename remotefile1 remotefile2

Rename a remote file from remotefile1 to remotefile2.  Note that both parameters should be filenames, not full paths.

Can use ren as an abbreviation.

lrename localfile1 localfile2

Rename a local file from localfile1 to localfile2.  Note that paths can be used as well as filenames.

Can use lren as an abbreviation.

delete remotefile

Delete a remote file in the current remote working directory.

Can use del as an abbreviation.

ldelete localfile

Delete a local file in the current local working directory, or specify a path for the file to be deleted.

Can use ldel as an abbreviation.

mdelete  wildcard

Delete multiple remote files that match the wildcard in the current remote working directory.

Wildcards supported are '?' for a single matching character, and '*' for multiple matching characters. e.g. to delete all text files in the current remote directory, use mdel *.txt

Can use mdel as an abbreviation.

mput wildcard

Upload multiple local files that match the wildcard in the current local working directory to the current remote working directory.

Wildcards supported are '?' for a single matching character, and '*' for multiple matching characters. e.g. to upload all text files from the current local working directory, use mput *.txt

mget wildcard

Download multiple local files that match the wildcard in the current remote working directory to the current local working directory.

Wildcards supported are '?' for a single matching character, and '*' for multiple matching characters. e.g. to download all text files from the current remote working directory use mget *.txt

close

Closes the connection to the remote server.

Can also use bye, quit, exit or disconnect.

quote command

Sends the quoted command to the server and displays the response.

site parameters

Sends a SITE command to the FTP server with the supplied parameters. These parameters can vary widely between FTP servers. This command is not applicable to SFTP servers.

For example site CHMOD 0600 /home/user/privatefile might be used to change the permissions of a file on an FTP server that supports this feature.

auth

Change from unencrypted 'plain' FTP into secure FTP.

protect clear

or

protect private

Change the protection level of the data channel in FTPS.

Supported options are clear (or c) to set data channels to unencrypted, and private (or p) to set data channels to encrypted. e.g. protect clear

Alternatively private has the same effect as protect private, and clear has the same effect as protect clear.

An abbreviation for protect is prot, which combined with the argument abbreviations means that to set the data channels to unencrypted could be done with prot c, and to set to encrypted could be done with prot p.

clear

In FTPS, change the protection level of the data channel to private. Identical to protect private.

private

In FTPS, change the protection level of the data channel to private. Identical to protect private.

ccc

In FTPS, clears the control channel, setting it back to plain unencrypted text. This can be useful when using firewalls, which need to be able to inspect the control channel to open data channel ports.

Once ccc has been called, no more protect commands can be used. This is a security measure inherent in the protocol.

record recordfile

Record subsequent commands to the supplied filename. Most useful from within the shell to record a session.

stop

Stop recording commands to file.