The LIST command gets a list of file names from the remote FTP server.
LIST ---- PATH ---------- directory path -------------------->
>-- FORMAT -------- *AUTO ----------------------------->
>-- DATEFORMAT ---- *NONE ----------------------------->
>-- DATALINK ------ *PASV -----------------------------|
If no PATH keyword is present, the current directory is used. The path can contain operating system wild characters.
The default value *AUTO uses auto-detect list format:
When using FTP between IBM i servers it is important to note the FTP attributes LISTFMT value (use CHGFTPA). For example, if the FTP Attributes has LISTFMT(*UNIX) then using LIST PATH(/TMP/*.*) FORMAT(*ISERIES) will not return any data. Changing to FORMAT(*UNIX) or using the SITE COMMAND(LISTFMT 0) will return data.
The default value *NONE means that no formatting is applied to the date field. Dates are formatted to ISO8601 format.
The DATALINK keyword determines how the "control" session is initiated. The default value is *PASV.
In passive mode, *PASV, the FTP the client initiates both connections to the server. Passive mode causes the FTPService to send a PASV subcommand to the remote FTP server, the FTP server returns the port number of the socket server it has started and a data transfer channel is established from the local server using this port number. This is known as "Passive FTP" and is often used to get around firewall difficulties. Using "Passive" FTP, the local server establishes the second connection, not the remote FTP server. Most firewalls will allow your computer to transfer files in this second connection to the remote FTP server (just as it allowed your computer to establish the first connection).
Port mode, *PORT, causes the FTPService to start a socket server and informs the remote FTP server via the PORT subcommand of the port number this socket server is listening on, the remote FTP server then connects to this socket server and a data transfer channel is established.
Refer to Technical Specifications for more information.
Comments / Warnings
RDML Clients require the list definition to be passed using the SERVICE_LIST keyword. The list object argument requires one, two or five fields.
If a one field list is being used, then the unprocessed lines are added to the list.
If a two field list is being used, the first field receives the file type and second field receives the file name.
If a five field list is being used, the first field receives the file type , the second field receives the date, the third field receive the time, the fourth field receives the size and fifth field receives the file name.
The type field can contain the following values:
DEFINE FIELD(#TYPE) TYPE(*CHAR) LENGTH(1)
DEFINE FIELD(#FILE) TYPE(*CHAR) LENGTH(80)
DEF_LIST NAME(#WRKLST) FIELDS((#TYPE) (#FILE)) TYPE(*WORKING) ENTRYS(100)
USE BUILTIN(JSM_COMMAND) WITH_ARGS('LIST SERVICE_LIST(TYPE,FILE)') TO_GET(#JSMSTS #JSMMSG #WRKLST)
use builtin(jsmx_command) with_args(#jsmxhdle1 'list path(/tmp/*.*) format(*unix)') to_get(#jsmxsts #jsmxmsg #worklist)