List FTP Server Directories

Lists all directories that are inside the 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.

ftpList --type(FtpType) --host(String) [--useanonymous(Boolean)] [--useprivatekeyauthentication(Boolean)] --sftpusername(String) [--ftpusername(String)] [--password(String)] --remotepath(String) --privatekeyfile(String) (String)=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 useanonymous 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 on the server of the files the command will list.
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. For more information about supported file types, see privatekeyfile parameter options

privatekeyfile parameter options

The following private key file types are supported:

  • RSA in OpenSSL PEM and ssh.com format
  • DSA in OpenSSL PEM and ssh.com format
  • ECDSA 256/384/521 in OpenSSL PEM format
  • ED25519 in OpenSSH key format

Output parameters

Designer mode label Script mode name Accepted variable types Description
Directories value Text Returns a list that contains all the directories found on the server.

Example

The following example shows how to list all directories contained on a server via FTP.

defVar --name listedDirectories --type String
ftpList --type "Ftp" --host hostAddress --username userName --password userPassword --remotepath directoryPathForList listedDirectories=value
Remember:For this example to work properly, it is necessary to use a valid host, with valid username and password for access.