GET

The GET command will receive the contents of a remote file and save it to a local file. The file specified by the FROM keyword is retrieved from the remote FTP server, using the DATALINK mode. The local server will store the file using the path specified by the TO keyword.

 

 GET --------- FROM ----------------- file path ------------------>

 

           >-- TO ------------------- file path ------------------>

 

                                                           Optional

 

           >-- NOT_EXIST ------------ *STATUS -------------------->

 

           >-- FROM_ENCODING -------- value ---------------------->

 

           >-- TO_ENCODING ---------- value ---------------------->

 

           >-- CONVERT -------------- *NO ------------------------>

                                      *YES

 

           >-- RECORD_SIZE ---------- 1024 ----------------------->

                                      integer

 

           >-- RECORD_DELIMITER ----- *NONE ---------------------->

                                      *LF

                                      *CRLF

 

           >-- DATALINK ------------- *PASV ----------------------|

 

Keywords

FROM

Nominate the remote file path to be copied from the remote FTP server.

See also CHGDIR command.

TO

Nominate the local file path where the file is to be placed on the remote FTP server.

See Comments / Warnings below.

NOT_EXIST

If NOT_EXIST(*STATUS) keyword is specified on the command, a NOT_EXIST status is returned if the remote file does not exist.

FROM_ENCODING

Encoding is used to convert the FROM file content to an intermediate Unicode string.

A default value is obtained from the 'from.encoding' property resource. If no property resource is located the value defaults to Cp037.

Only used this keyword when CONVERT is set as *YES.

TO_ENCODING

Encoding is used to convert the intermediate Unicode string to target encoding.

A default value is obtained from the 'to.encoding' property resource. If no property resource is located the value defaults to ISO8859_1.

Only used this keyword when CONVERT is set as *YES.

CONVERT

The default is *NO conversion.

A value of *YES indicates that after each record size read, the data will be converted to the specified target encoding and sent to the FTP server.

RECORD_SIZE

The default value is 1024 bytes.

Nominating an integer value specifies the read size used on the source file.

Refer to PUT Comments / Warnings.

RECORD_DELIMITER

The default value is *NONE.

A value is only required when keyword CONVERT is set as *YES. In this case the end of record marker to be added to the end of each converted record read can be nominated as either *LF (Line Feed) or *CRLF (Carriage Return, Line Feed).

For more information refer to 5.1.7 Carriage Return, Line Feed and New Line

DATALINK

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

If the FROM file is an IBM i physical file:

Normal stream files can also be converted:

Examples

The following examples use the GET command to receive the contents of a remote file and save it to a local file.

RDML

 

CHANGE FIELD(#JSMCMD) TO('GET TO(order.xml) FROM(/xmldata/order.xml)')

USE BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET(#JSMSTS #JSMMSG)

 

RDMLX

 

#jsmcmd := 'get from(' + #jsmfrom + ') to(' + #jsmto + ')'

use builtin(jsmx_command) with_args(#jsmhandle #jsmcmd) to_get(#jsmsts #jsmmsg)