Delete File from FTP Server

Deletes a file from a server using the FTP or SFTP protocol.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

ftpDelete --type(FtpType) --host(String) [--useanonymous(Boolean)] [--useprivatekeyauthentication(Boolean)] --sftpusername(String) [--ftpusername(String)] [--password(String)] --remotepath(String) --privatekeyfile(String) (Boolean)=value

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Type type Required FtpType Type of protocol to be used: FTP or SFTP.

Both protocols are used to transfer files from one computer to another, but SFTP requires an SSH server connection. Encrypted FTP connections (FTPS) are not supported.
Server Path host Required Text Server connection URI.
Anonymous connection useranonymous Optional Boolean Enable to hide the username, establishing an anonymous connection.
Use private key authentication useprivatekeyauthentication Optional Boolean Enable to enter the path to the private key file.
SFTP username sftpusername Only when Type is SFTP Text Username to access the server via SFTP.
FTP username ftpusername Optional Text Username to access the server via FTP.
Password password Optional Text User password to access the server via FTP.
Remote Path remotepath Required Text Path of the directory where the file is located in the server.
Note:Do to not include the filename on the path.
Private key file privatekeyfile Only when Use private key authentication is True Text Path to the private key file.

Output parameters

Designer mode label Script mode name Accepted variable types Description
Success value Boolean Returns True if the file was deleted successfully. Otherwise, returns False.

Example

The following example shows how to delete files from a server via FTP.

defVar --name success --type Boolean
ftpDelete --type "Ftp" --host hostAddress --username userName --password password --remotepath fileToDeletePath success=value
Remember:For this example to work properly, use a valid host, with valid username and password for access.