<< back to sysax.com Product page |
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.
Passwords and other strings can be protected using the setprotectedvar command. The contents of a protected variable will be automatically decrypted when the variable is passed to the ftpconnect* group of commands, the certload command, or the pkeyload command. In all other cases, including printing of the variable, only the encrypted value is made available. The encrypted string for a protected variable should be generated from the command line using the -protectstring option.
Exhibit 4.1. Syntax of connect command for ftp
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 ftpconnectssli command should be used if an implicit FTPS connection is required. The ftpconnectsslc command can be used if only the control connection needs to be encrypted using SSL.
Exhibit 4.2. Syntax of connect command for ftps
ftpconnectssl <address string>, <port number>, <username>, <password> [, optional: <account>]; ftpconnectssli <address string>, <port number>, <username>, <password> [, optional: <account>]; ftpconnectsslc <address string>, <port number>, <username>, <password> [, optional: <account>]; |
Client side SSL certificates may be used for authentication of a client to the remote server. The certload command enables a client side certificate to be loaded. The certificate must be loaded before establishing a connection using ftpconnectssl and must be in the pem format.
Exhibit 4.3. Syntax of certificate loading command
certload <certificate file>, <private key file> [, optional: <passphrase>]; |
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.
Exhibit 4.4. Syntax of connect command for sftp
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.
Exhibit 4.5. Syntax of privatekey loading command
pkeyload <private key file> [, optional: <passphrase>]; |
If it is necessary to connect using a http proxy server, the proxyhttp command should be called before establishing a connection.
Exhibit 4.6. Syntax of command for using http proxy server to connect
proxyhttp <proxy address>, <proxy port> [, optional: <proxy username>, <proxy password>]; |
The ftpdisconnect command is used to close a connection that was established using any of the above commands.
Exhibit 4.8. Example for commands for connecting to remote hosts
ftpconnect "ftp.mysite.com", 21, "username", "password"; #connect to a non-secure ftp server if success eq ftpresult begin end certload "c:\\certs\\mycert.pem", "c:\\keys\\myprivkey.pem", "keypass"; ftpconnectssl "ftp.securesite.com", 21, "user", "pass"; # connect to an SSL (FTPS) based secure server using client side certificate pkeyload "c:\\keys\\privkey.pem", "keypass"; ftpconnectssh "ftp.securesite.com", 22, "", ""; #connect to an SSH (SFTP) based secure server using public key auth setprotectedvar ~mypassword, ":#!FEC016d09ab332ff7edfdbe90dd212c8b0e37dd033bc6cd7ad3d31f5a4075e94d1f1c0ef8cb423837f63e00000000000000000000000000000003UsokpdRYrZyypl5Ir9XN4Jwp0cXNWv8f6mD4vq4d4WQZOxQFFxGWFuk1ZFo9OXw/ZGCM8g5Z08ASGrrdPLDDux2QA/6wtec7/yUg1mmVUAdLeWE="; ftpconnect "ftp.mysite.com", 21, "username", ~mypassword; #connect to server - here, a protected variable is passed in as the password ftpdisconnect; #disconnect from the remote ftp server |