Note: This page was adapted from a question-and-answer quick reference written by Thibault Dambrine.
 
This page contains a quick reference for FTP techniques on the iSeries about:
  • Troubleshooting Translation Tables
  • Troubleshooting FTP Clients on a PC Server
  • Retrieving MGET Results
  • Creating a File for FTP Scripts
  • Troubleshooting the PASV Command on the iSeries
  • Monitoring PING Messages
  • Line Wrapping in FTP Source Commands
  • Controlling the Transmission of Trailing Blanks
  • Transferring Libraries or Other Objects Using FTP
  • Unpacking Fields in a Physical File before FTP Transmission
  • Signing On via FTP Not Updating User Profile with Date and Time Last Accessed
  • FTP QUOTE Operation Working from One Location but Not Another
  • Overriding the FTP Default Port
  • Exporting an iSeries DB2 File to Microsoft Excel

Troubleshooting Translation Tables

If you are sending a file with FTP from the iSeries with text in mixed languages (for example: Arabic and English), you may encounter issues with the translation table for the double-byte characters for the Arabic language on the iSeries. To resolve the issue:
  1. Use RTVTBLSRC to retrieve the source of the QASCII translation table.

    The contents of the translation table are put in a regular source file.

  2. Modify the retrieved translation table, using values that meet the specific requirements of the transfer.

    Note: This table contains only the translation. For example: In QASCII, EBCDIC Hex 04 translates to ASCII Hex 9C. In the translation table, only 9C displays. To view this type of table, use WRKTBL and type 5 next to the table to view. For a list of hex tables for foreign languages, see ftp://ftp.unicode.org/Public/UNIDATA/.

  3. Use CRTTBL to re-create the translation table.

    Note:

    • The table type is *CVT.
    • Do not to override a standard IBM table, like QASCII or QEBCDIC. Rather, create your own version of a new table. For example: XASCII or XEBCDIC.
  4. Use the FTP command to start an FTP session and press F4 to prompt it.

    The remote system parameter displays.

  5. Press F10 to display more parameters,
  6. For the names of the incoming and outgoing ASCII/EBCDIC tables to use, enter your customized version of the translation table. For example: XASCII or XEBCDIC.
  7. Test the new translation table by sending files with FTP that have the translation issue.

Troubleshooting FTP Clients on a PC Server

If you need a recommendation for a reliable FTP client, try WS_FTP Server, which is available on the IPswitch website: http://www.ipswitch.com/.

Problem:

You are using the WAR FTP Daemon FTP client on the PC server, and you can GET files from the PC to the iSeries but not PUT them. An empty shell of the file is created on the PC, but no data transfer takes place. The WAR FTP Daemon displays the message:
 
227 Entering Passive Mode (nn,n,n,nnn,n,nn)125 Ready to receive "my-file-name" . Mode Stream Type Ascii

Solution:

Check the manual for the FTP client for all possible settings. In this case, turn off the PASV subcommand.
 

Retrieving MGET Results

Problem:

When you use MGET to retrieve multiple files from a Novell network to the iSeries using FTP, the files go the the QGPL library instead of the iSeries folder you want them in.
 
For example:
mget *.exe /qdls/plant

Solution:

MGET places the results in your current library. If you do not have a current library specified, the default is QGPL.
  1. Run the following command, where XYZ is the library you want to send files to:

    CHGCURLIB CURLIB(XYZ)

  2. Run MGET alone:

    mget *.exe

    The files go to the current library you specified for the job.

Creating a File for FTP Scripts

 
The INPUT file that will contain the FTP script should be a one-field file:
  1. Create a file with the following source:

    ---------------------------------------------------------------------------
    A R REC24 TEXT('Import Record Fmt')
    A SRCDTA 80A TEXT('Source Data Field')
    ---------------------------------------------------------------------------

  2. Create a source file where you enter the FTP script.

    Note: All source files have three fields: the sequence number, the date, and the source data.

  3. Use PDM to create your script in your source file member.
  4. Send the content of the source-file member to the FTP script source file, using the convert source (*CVTSRC) format option:

    CPYF FROMFILE(CATDA7/QSRC) TOFILE(CATDA7/FTPINPUT) FROMMBR(FTPINST) TOMBR(*FIRST) MBROPT(*REPLACE) FMTOPT(*CVTSRC) 

 

Troubleshooting the PASV Command on the iSeries

Problem:

Your client automatically issues the PASV sub-command with a PUT or GET, and you have an occasional disconnect issues when an ack does not come back from the first PASV.

Solution:

Use SENDPASV to turn off PASV. SENDPASV (Specify Whether to send a PASV Sub-command) is an FTP client sub-command that specifies whether or not to send a PASV subcommand to the FTP server when doing a data transfer or issuing the DIR and LS sub-commands.

SENDPASV [ 0 | 1 ]
 
If you do not use a parameter, SENDPASV toggles between 1 (ON) to 0 (OFF). Valid parameters values are:
  • 0 - Do not send a PASV subcommand
  • 1 - Send a PASV subcommand. This is the iSeries default.

Monitoring PING Messages

Problem:

You have a CL that monitors the PING and, if it fails, does not try to send via FTP. However, the MONMSG of TCP3206/TCP3202/TCP3213 are not working.
 
Sample code:
PGM/* Verify connection to Host before attempting Transfer */PING RMTSYS('1.1.1.1')MONMSG MSGID(TCP3202 TCP3206)EXEC(SNDPGMMSG + MSG('Ping to remote not successful'))ENDPGM
Sample results:
Verifying connection to host system 1.1.1.1.No response from host within 1 seconds for connection verification 1.No response from host within 1 seconds for connection verification 2.No response from host within 1 seconds for connection verification 3.No response from host within 1 seconds for connection verification 4.No response from host within 1 seconds for connection verification 5.Connection verification statistics: 0 of 5 successful (0 %).

Solution:

This occurs when you use a numeric IP address (for example: 1.1.1.1) instead of a IP table configured system name (for example: SYSTEMR). Configure a IP system name and use that name in your program instead of a numeric IP address. Use the following code for testing:

PGMDCL VAR(&LOCATION) TYPE(*CHAR) LEN(10) VALUE(SYSTEM1)PING RMTSYS(&LOCATION)MONMSG MSGID(TCP3202)EXEC(SNDPGMMSG MSG('Ping to remote location does not work'))ENDPGM

Line Wrapping in FTP Source Commands

When you run FTP on the iSeries in batch mode and PUT a file with a very long name to another very long name, you will have issues with the source file (script file) record length. The iSeries does not support FTP command line wrapping, so you will have to change your process in another way.
 

Controlling the Transmission of Trailing Blanks

Problem:

You are sending a 108 byte file to a UNIX system. The last 26 bytes are blank so they are lost in transmission. You cannot fill the file with nulls because nulls are equal to a numeric.
 

Solution:

Use a combination of two FTP subcommands: LOCSITE TRIM 0 and ASCII. The LOCSITE FTP subcommand specifies whether or not to transfer the trailing blanks in a database file to the remote server. You can use this command in three ways:
  • TRIM 0 - Turn off trim. Trailing blanks of database records are sent.
  • TRIM 1 - Turn on trim. Trailing blanks of database records are NOT sent. This is the default setting.
  • TRIM - Display the current trim setting. 
 

Transferring Libraries and Other Objects using FTP

To transfer objects or complete libraries with FTP, you need to use a save file (type *SAVF). A SAVF file is a physical file with records 528 characters long. To transfer the contents of a SAVF from one iSeries to another:
  1. Create a save file (CRTSAVF) on the source machine.
  2. Save objects in the SAVF.
  3. Create a save file (CRTSAVF) on the target machine.
  4. FTP the save file to the remote iSeries:

    BINARY PUT FROMLIB/SAVEFILE TOLIB/SAVEFILE

    For automated procedures, the SAVF does not have to be on the target iSeries:

    put /qsys.lib/catda7.lib/fromsavf.savf /qsys.lib/catda7.lib/tosavf.savf

Unpacking Fields in a Physical File before FTP Transmission

Use the CPYTOIMPF (Copy to Import File) command.
 
For example:
CPYTOIMPFFROMFILE(DB2FILE)TOFILE(EXPFILE)FLDDLM(';') RCDDLM(X'07')
 
All records of externally described file (DB2FILE) are copied to import file (EXPFILE), fields are delimited by a semi-colon (;), and each record is delimited by a hexadecimal ('07') character.
 

Signing On via FTP Not Updating User Profile with Date and Time Last Accessed

Problem:

When you sign on to the iSeries via FTP, the date and time last accessed in the user profile is not updated. You have users who only access the iSeries via FTP, and also have a program that deletes user profiles after a certain time limit. For security reasons, you do not want to set the password expiration date to *NOMAX.
 

Solution:

When you sign on via FTP, a special FTP server job handles the session, instead of a normal QINTER sign-on session. It is not possible to force FTP signon to trigger an update to the user profile automatically for the last access date.
 
There are two techniques you can try to resolve this issue:
  1. Use the QSYCHGPR API to change the sign-on date and time to current. Call this API from an exit program or, if you are executing QUOTE RCMD within FTP, embed the API in this command.
  2. Deal with the security-exposure issue. Either:
    1. Use an FTP exit program to capture the FTP sign-on event and write or update physical file record containing the user profile and the sign-on date and time. Then set up the automatic user-profile deletion program to check both the user profile last used date and time and the last access date and time in the file the FTP exit program wrote to.

      FTP exit programs accept and return the the following parameters:

      • Application ID (for example: FTP Client)
      • Operation ID (for example: Sending a file)
      • User Profile
      • Remote IP address
      • Length of remote IP address
      • Operation
      • Length of operation
      • Allow Operation
    2. Use a complete iSeries internet and TCP/IP security solution, such as PowerLock.
 

FTP QUOTE Operation Working from One Location but Not Another

Problem:

You can issue the QUOTE sub-command from an iSeries FTP session, but another user in an iSeries FTP session at a different location cannot. The log file contains:
reply code 500 "Syntax error; command unrecognized."
 
For example: You can FTP a file to a client and then successfully execute: QUOTE RCMD CALL LIBNAME/PGMNAME. Another user in a different location logs on with the same user name and tries to FTP the file to the same client, and the QUOTE statement always fails.
 

Solution:

One of the following 3 IP protection tools is running on either the other user's or the client's network and is not allowing the QUOTE statement:
  • An external firewall.
  • An iSeries IP security software system, such as PowerTech PowerLock.
  • An iSeries exit program.
iSeries FTP exit programs can accept 7 different parameters to decide whether to block a command, such as QUOTE, including the remote IP address:
  • Application ID (for example: FTP Client)
  • Operation ID (for example: Sending a file)
  • User Profile
  • Remote IP address
  • Length of remote IP address
  • Operation
  • Length of operation
  • Allow Operation
Check with the network administrators for the other user and the client about the iSeries TCP/IP set-up, whether any settings differ based on IP address, and whether QUOTE is an allowed FTP sub-command.

Overriding the FTP Default Port

Problem:

When you use a standard FTP command on the iSeries, it automatically routes the transmission through port 21. Instead, you want to redirect FTP to use another port (for example: 2888) in the initial FTP command.
 

Solution:

FTP to either an IP address or a named server, followed by a blank character and then the port number.
 
For example: This is a sample command and response where the FTP client communicates on Port 2888:
FTP RMTSYS('111.222.133.114 2888')Connecting to remote host 111.222.133.114 using port 2888.220 hksvr005 Microsoft FTP Service (Version 4.0). 
 

Exporting an iSeries DB2 File to Microsoft Excel

Problem:

You have a file with a mix of character, packed, and zoned fields, some with positive and some with negative values, that you need to export to a Microsoft Excel spreadsheet.
 

Solution:

The CPYTOIMPF command allows you to both unpack the numeric data so that it can be translated from EBCDIC to ASCII while keeping the signs and insert a delimiter between each field, so that Excel can identify field boundries when importing.

 
For example: To copy the file DB2FILE to an import file EXPFILE, unpack the he packed fields, keep the zone fields zoned, delimit each field with a semicolon (;), and delimit each record with X'07', use:
 
CPYTOIMPF FROMFILE(DB2FILE) TOFILE(IMPFILE) FLDDLM(';') RCDDLM(X'07')

Then use FTP to send EXPFILE as a TXT file (for example: as IMPFILE.TXT) to a PC or to a Local Area Network drive. You can then import it to a Microsoft Excel spreadsheet.


Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: December 10, 2016