The professional tool to automate FTP and secure FTP transfers. Automated FTP & Batch FTP

SETPROTOCOL

Set the protocol used for the FTP connection. Use this command to enable secure FTP (FTPS).

Note: ScriptFTP currently supports FTP (common FTP) and FTPS (FTP over SSL). SFTP will be supported in future versions.

Syntax: SETPROTOCOL(protocol)

  • protocol:
    FTP For standard FTP connections. This is the default value.
    FTPS_EXPLICIT_ENCRYPT_DATA Use this value if you want to encrypt file contents and login (user and password).

    ScriptFTP will connect to the FTP server using a standard FTP connection and will then send a specific command to enable SSL mode before logging in. Data connections used to transfer file contents will be encrypted.
    FTPS_EXPLICIT Use this value if you want to encrypt login (user and password) but don't care about file contents.

    ScriptFTP will connect to the FTP server using a standard FTP connection and will then send a specific command to enable SSL mode before logging in. Data connections used to transfer file contents will not be encrypted.
    FTPS_IMPLICIT Use this value if you want to encrypt file contents and login (user and password). Note that the FTP explicit mode (FTPS_EXPICIT and FTPS_EXPLICIT_ENCRYPT_DATA) is more widely adopted by FTP servers..

    Implicit security mode will automatically establish an SSL connection as soon as ScriptFTP starts connecting to an FTP server. The port 990 will be used for this mode. Control and data connections will be encrypted.

Remarks:

  • Changes will take effect the next time OPENHOST is invoked in the script.
  • Standard FTP is used by default. There is no need to invoke SETPROTOCOL in your script if you do not want to use FTP over SSL (FTPS).
  • Depending on the selected protocol SETPROTOCOL will change the TCP port used for connecting to the FTP server. Use SETPORT after calling SETPROTOCOL if you want to set your own value.

Command History:
FTPS_EXPLICIT_ENCRYPT_DATA was added in ScriptFTP 2.1 build March 14th 2006

Return value:
This command always returns "OK".

See Also:
OPENHOST
SETPORT

Examples:

# Connect to ftp.myhost.com using FTPS
SETPROTOCOL(FTPS_EXPLICIT_ENCRYPT_DATA)
OPENHOST("ftp.myhost.com","myuser","mypassword")
GETFILE("*.*")
CLOSEHOST

# Connect to ftp.myhost.com using secure FTP
# download sales.xls and upload it to a local server


# The file is downloaded to the Windows temp directory
LOCALCHDIR("C:\WINDOWS\TEMP")

# Use secure FTP
SETPROTOCOL(FTPS_IMPLICIT)
OPENHOST("ftp.myhost.com","myuser","mypassword")

GETFILE("sales.xls")
CLOSEHOST

# Go back to standard FTP
SETPROTOCOL(FTP)
OPENHOST("192.168.1.53")
PUTFILE("sales.xls")

CLOSEHOST

# Delete sales.xls
EXEC("del sales.xls")