Unattended File Transfers Using FTP

System administrators commonly initiate FTP sessions to other systems' FTP clients using the FTP client capability on the iSeries. Users could also connect to the iSeries FTP server with their systems (Windows, Linux, etc.) FTP client and transfer data.

When transfers must occur during off hours or at scheduled intervals, an automated or unattended FTP transfer may be used. iSeries, Windows, UNIX and Linux systems have the capability to provide unattended FTP data transfers. This article explains how to perform unattended FTP data transfers, both those initiated from the iSeries and those initiated from the remote system to the iSeries.

Because FTP is inherently an interactive process (users commands from an FTP client command line), we must provide a method where the FTP commands are coming from a different source - a file of commands. Obtaining these commands from a different source is known as redirection. We'll redirect the input to the FTP process from interactive commands being entered on a command line to obtain those same commands from a file.

The iSeries FTP client obtains commands from an input file (INPUT). The client can also optionally redirect the output to a file. This output redirection allows another program in the job stream to check the FTP transfer's status. The key for this technique is to override INPUT to a file containing the FTP commands. We may also wish to override an output file (OUTPUT) to a file containing the results or messages of the FTP operation. (Note: The file names INPUT and OUTPUT are used internally in the iSeries FTP client process and required to perform unattended FTP transfers.) Once the files have been overridden, we initiate the FTP transfer.


/*    Clear the FTP results output file                          */

/*    Override the input (commands) and output (results) files   */

/*    Transfer the file using the commands in the FTPIN member   */
             FTP         RMTSYS(FTPREMOTE)

/* Delete the overrides */
             DLTOVR      FILE(INPUT)
             DLTOVR      FILE(OUTPUT)



In the CL program (FTPTOWIN) above, the INPUT file is overridden to MICHAEL/QFTPSRC.FTPIN. This causes the FTP process to read the commands from the file rather than expecting input from the keyboard. Accordingly, the OUTPUT file is overridden to MICHAEL/FTPRESULT. This causes the FTP process to write the resulting messages from the FTP process to the file rather than to the display. The FTP command initiates the transfer with the remote system (FTPREMOTE) and the FTP command input is read from INPUT and the output messages written to OUTPUT. The program then deletes the overrides and ends. This program could be modified to start the iSeries FTP server (STRTCPSVR SERVER(*FTP)) before the FTP command and end the iSeries FTP server (ENDTCPSVR SERVER(*FTP)) after the FTP command. This may be useful if you don't wish to leave the FTP server running, perhaps for performance or security considerations.

















Michael Ryan is a technical editor with IBM Systems Magazine. Michael can be reached at

comments powered by Disqus



2017 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

Directing i

How to enable IBM i for management by IBM Systems Director

Putting the "V" in Virtualization

IBM eServer line delivers on the promise of virtualization

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters