Syntax:

SETPROTOCOL(protocol)

  • protocol:

    FTP

    For standard FTP connections. This is the default value.

    SFTP

    For SSH FTP connections.

    FTPS

    For FTP over SSL connections. Use this value if you want to encrypt file contents and login (user and password). ScriptFTP will automatically establish a 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.

    FTPS_EXPLICIT_ENCRYPT_DATA

    For FTP over SSL connections. 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

    For FTP over SSL connections. 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

    Equivalent to the FTPS parameter seen above.

Remarks:

  • Changes will take effect when a new connection to the server is made. So use SETPROTOCOL before OPENHOST in your script.
  • Standard FTP is used by default. Unless you want to use FTPS or SFTP there is no need to use this command in your script.
  • Depending on the selected protocol SETPROTOCOL will change the TCP port used for connecting to the 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.
SFTP was added in ScriptFTP 4 on April 2013.

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 SFTP
SETPROTOCOL(SFTP)
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")