5.7.10 PUT
The PUT command is used to copy a local file to the remote FTP server.
Syntax:
Command |
Keyword |
Value |
Developer notes |
PUT |
FROM |
value |
Required. Local file path. |
TO |
value |
Required. Remote file path. |
|
FROM_ENCODING |
encoding |
Encoding is used to convert the FROM file content to an intermediate Unicode string. |
|
TO_ENCODING |
encoding |
Encoding is used to convert the intermediate Unicode string to target encoding. |
|
CONVERT |
*NO |
Default is No conversion. |
|
*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 |
integer |
An integer value specifies the read size, in bytes, to be used on the source file. |
|
*NOMAX |
This value sets the read size to the length of the source file. |
||
RECORD_DELIMITER |
*LF |
Add LF to the end of each converted record. |
|
*CRLF |
Add CRLF to the end of each converted record. |
||
*NONE |
Default. No record delimiter. |
||
DATALINK |
*PASV |
Default. Use passive mode. |
|
*PORT |
Use port mode. |
Example
PUT FROM(/folder/file.pdf) TO(/folder/file.pdf)
PUT FROM(/QSYS.LIB/MYLIB.LIB/MYFILE.FILE/MYFILE.MBR) TO(file.txt) CONVERT(*YES) RECORD_SIZE(423) RECORD_DELIMITER(*CRLF) FROM_ENCODING(Cp037) TO_ENCODING(Cp1252)
Comments / Warnings
If the FROM file is an IBM i physical file:
-
The RECORD_SIZE must match the total record length of the file.
-
Use the DSPFD command to determine the total record length.
-
All fields in the file should be of type CHAR.
-
A deleted record in the file will be read as a blank record, so use the RGZPFM command to remove deleted records from the file.
Normal stream files can also be converted:
-
After each record size read the data is converted.
-
The FROM file content must be single byte encoded, unless the RECORD_SIZE (*NOMAX) option is used, in which case the file is processed in one read and the conversion is applied to the entire file content.