Common AS/400 FTP questions answered

WAN engineers may have questions regarding AS/400 FTP. In this FAQ, get answers on some of the most common questions, such as how to make your AS/400 visible to an FTP server.

AS/400 FTP is a topic that can be difficult to fully understand, and thus questions are frequently asked about it on TechTarget’s IT Knowledge Exchange (ITKE).  Wide area network (WAN) engineers who are responsible for the File Transfer Protocol (FTP) setup and connectivity in AS/400 server environments -- formally renamed the "IBM iSeries" -- will find this FAQ guide useful. If a situation arises where a WAN engineer needs information about FTPing over the WAN using an AS/400 server, this FAQ page can provide the answers to some of the most frequent questions, including how to make the AS/400 visible to an FTP server, how to write batch programs and how to FTP using an AS/400 program. In this FAQ guide, we have compiled some of the most common questions and the best answers to each.

How do I make my AS/400 visible to an FTP server?

Answer: First, you need to get an external IP address from your ISP, and then you must set up a mapped IP address in your firewall. As long as the AS/400 has a working default route, the FTP server will be able to access the AS/400 using the external IP address.

On the other hand, if the AS/400 is the client, you need to run FTP from a command line (CL) to connect to the remote host. You should be able to communicate as long as the client has a route to that remote host and the firewall(s) are opened for FTP protocol.  

How do I run a program on AS/400 to FTP a FILE.savf? I know how to enter commands via the DOS window, but I'd like to use an AS/400 program (RPGLE or CLLE) by means of a PC file (FILE.savf) to an AS/400 savefile (FILEA) in a library (LIBA).

Answer: First, take your file (example.savf ) and drag it in Windows to /home/yourname directory on an AS/400.

Next, run this command:

TOMBR( '/qsys.lib/qgpl.lib/example.file' )

This results in a savefile created in QGPL named EXAMPLE.

In order for that to work, there are a few requirements. First, a NetServer server needs to be running on the AS/400, configured to be available from Windows Networking. In this example, /home/username must be configured as a shared directory and the File host server needs to be running in order for NetServer to access the IFS. Since most sites have NetServer and the File host server running, it’s probable that everything’s already set up.

If the BPCS download was saved directly into my /home/toml directory, then even the drag-and-drop wouldn't have been needed -- just the single command.

How do I write an FTP batch program to run on the AS/400 to a PPT file extension?

You need to create a 'script' file with your FTP commands in it, by either creating a file with all the commands or, if you need to do different transfers, by writing a program to build the file for you. In either case, you need something along the following lines:

cd remote_directory
lcd local_library
put local_file remote_file
get remote_file local_file

The following list explains what the commands above stand for:

  • remote_directory = directory or library on remote machine
  • local_library = library on local machine
  • local_file = file name on local machine
  • remote_file = file name on remote machine.

You may also need other commands like BIN or ASCII depending on what you're going to transfer and where you're transferring it to.

The best way to execute the script file is to create a small CL program with the following:

  1. Override FTP input to your script file:
    OVRDBF FILE(INPUT) TOFILE(YourLibrary/YourScript)
  2. Override FTP output to a log file (if this is skipped, messages go to the screen interactively or to the qsysopr message queue from batch):
  3. Start FTP with a hostname or FTP address:
    FTP RMTSYS(Your_Remote_System)
  4. Remove the overrides:

I am keeping daily running reports in My IFS called ABC folder (wrklnk ABC). This folder contains 10 CSV files with date extensions. How do I zip all CSV files and FTP to another system using AS/400?

Answer: There are various ways to create usable .ZIP files on AS/400s. One obvious way is to purchase a third-party product or utility that provides a nice, clean user interface of functions on the system or into program code that implements the algorithms used for "zipping" files.

If a purchase is out of the question or a fancy interface isn't needed, then AS/400s with Qshell installed can use the Java jar (or ajar) tool to create .ZIP compatible files. For basic usage details, type "jar" on a Qshell command line. For ajar, see the ajar - Alternative Java(TM) archive page.

How do I copy the IFS file from one directory to another file and then FTP that file?

To copy a file from one IFS location to another, use the CPY command: 

CPY OBJ('/MyDirectory/MyFile.csv') TOOBJ('/MyOtherDirectory/MyOtherFile.x')

To send an IFS file via FTP, use the FTP or STRTCPFTP command to start a file transfer session. After logging in, enter namefmt 1 to address the hierarchical file system of the IFS. From there, the cd (change directory) and lcd (local change directory) command lines will allow you to navigate the directory structure. Finally, the put command is what copies the specified file from the source location to the target location.

How do I FTP a file to the R drive on the Zebra 170Xill printer on AS/400?

Answer: You can define the Zebra as a character printer such as Epson 850. With this configuration, it is not necessary to FTP the print file, because the operating system can manage sending the spool file. In order to configure the printer as a character printer, configure it as generic text only during installation.  When writing from the AS/400, there is no conversion under this configuration. The Zebra printer can be attached to the PC via a USB.

We receive files via FTP to an NT card on the AS/400, and I can easily FTP from the NT card to the AS/400. Is there a way to start a job on the AS/400 from the NT card or the IFS to process this file?

Answer: One possible option is using the RMTCMD capability in a DOS batch file which would be something like this:


The RMTCMD command can work, but it will need someone to supply user profile info and a password every time it runs. So for a server to execute RMTCMD, you could use the CWBLOGON command from an iSeries Access install to supply a profile and password.

After the RMTCMD completes, run CWBLOGON again with parameters to clear the profile and password cache.

Run the commands with /? as the only parameter to see the Windows help text for them.

I need to find a better alternative to FTP for transferring files from an FTP server to the iSeries. The files being transferred are based on a server that is being replaced and FTP will not be put on the new box.

The current process uses FTP dir command to list the files present to an output logfile, which is then processed to create a script "on the fly" to FTP the file up to the iSeries. I considered setting up a NETSHARE drive on the iSeries and then transferring from there, but the office is a remote site on a WAN that also passes hundreds of 5250 type sessions -- plus GUI and other miscellaneous data and applications -- through the connection, and I don't wish to impact the interactive traffic.

Answer: When both systems are iSeries, the list could include DDM, SNDNETF, QFileSvr file system of IFS, etc. All of these will have the drawback of potentially impacting interactive users who are sharing the same communication channel -- though there are some knobs such as TCP Quality of service (QoS) available to you. Depending on the data, you may be able to reduce the impact on the communication line by way of data compression.

Another alternative, depending on the data source, would be to send the individual records as they become available on the source system rather than sending entire files. If we're talking database records, a simple trigger program could send the records over in real time -- with scenarios such as writing directly to a socket, writing to a DDM *DTAQ or writing to a DDM database-- or, along similar lines, you could journal the file and receive the journal images in real time for transmission to the target system (or use remote journaling). This should minimize the potential impact to interactive users since the data is spread out over a wider time period, and you could also build in your own throttles/controls.


This was last published in October 2011

Dig Deeper on WAN protocols

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.