decorative banner

Previous | Next               Table Of Contents > 3 File transfer commands > 3.1 Connecting to remote hosts

3.1 Connecting to remote hosts

Connections to a remote FTP server are established using the ftpconnect command. The IP address of the remote server must be specified as the address string. The port number indicates the port where FTP connections are accepted by the remote server. The default port number for regular FTP connections is 21. The username and password strings are required to log into a specific user account. If the FTP server allows anonymous access, the username should be ftp and the password should be the user's email address. Some legacy FTP servers may also require an optional account string. The ftpresult predefined status flag is set to the predefined constant success if the command completed successfully.

The syntax is

ftpconnect <address string>, <port number>, <username>, <password> [, optional: <account>];


Secure connections using the SSL protocol (also known as FTPS) are established using the ftpconnectssl command. The ftpconnectsslc command can be used if only the control connection needs to be encrypted using SSL.

The syntax is

ftpconnectssl <address string>, <port number>, <username>, <password> [, optional: <account>];

ftpconnectsslc <address string>, <port number>, <username>, <password> [, optional: <account>];


Secure connections using the SSH protocol (also known as SFTP) are established using the ftpconnectssh command. The default port number for ssh connections is 22.

The syntax is

ftpconnectssh <address string>, <port number>, <username>, <password> [, optional: <account>];

Public key authentication for SSH connections allows clients to use a private key for authentication instead of a password. The pkeyload command enables a private key to be loaded to perform SSH public key authentication. The key must be loaded before establishing a connection using ftpconnectssh and must be in the pem format.

The syntax is

pkeyload <private key file> [, optional: <passphrase>];


The ftpdisconnect command is used to close a connection that was established using any of the above commands.

The syntax is



Some examples are

ftpconnect "", 21, "username", "password"; #connect to a non-secure ftp server
if success eq ftpresult begin


ftpconnectssl "", 21, "user", "pass"; # connect to an SSL (FTPS) based secure server

pkeyload "c:\\keys\\privkey.pem", "keypass";
ftpconnectssh "", 22, "", ""; #connect to an SSH (SFTP) based secure server using public key auth

ftpdisconnect; #disconnect from the remote ftp server

Previous | Next