Having written an "automated" FTP command for the AS/400 in 1996, I read Tim Granatir's recent FTP tip with considerable...
interest. While the approach taken in Tim's tip was similar to mine -- and numerous others -- it doesn't address two of the biggest shortcomings of FTP on the iSeries. For one, the ability to dynamically generate a JOBLOG from each/every FTP client session. More than that, how can you immediately terminate an FTP session when a recognizable error condition occurs? The answer: a trigger.
As FTP writes its standard output (STDIO) to file OUTPUT, it is entirely possible to attach a database trigger to OUTPUT, where by, the triggered program "receives" the contents of the record being added to OUTPUT. The triggered program can then interpret the record for recognizable FTP error conditions. As the triggered program executes in the same program/invocation stack as the FTP process, the triggered program, upon identifying a valid FTP error condition, can issue a CPC2402 *ESCAPE message. This terminates the FTP client session immediately.
The attached .ZIP file contains my "twist" on automating FTP on the iSeries. While very similar to Tim's, I provide for immediate termination of FTP client sessions and the "echoing" of FTP Client subcommands and responses to the jobs JOBLOG. The following summarizes the components in the .ZIP file:
STRFTP -- Command line interface.
STRFTPCL -- STRFTP command processing program; creates required files in QTEMP, adds trigger and performs other trivial, yet essential tasks.
WRTSRCDTA -- Like Tim's FTP15R, it writes entry for each FTP command supplied to STRFTP.
FTPERRORS -- Triggered program; like Tim's FTP200c, it processes each STDIO record written monitoring for specific FTP errors; also uses OS/400 API's to "echo" FTP commands/responses to JOBLOG.
FTPERRORS2 -- Similar to FTPERRORS, performs second pass through STDIO output file to handle use of SYSCMD, SYSC and "!" subcommands. As this was written in 1996, I can't remember why but I think it had/has something to do with the lack of uniform standards of functions across FTP implementations.
APIERRORS -- DDS defining OS/400's API error Data Structure. Currently implemented as External DS, but not required. It's simply a matter of personal preference.
- Fast guide to Redbooks and articles on FTP for the iSeries
Need information fast on FTP for the iSeries? Take a look at these publications. We've found Redbooks, articles and FAQs for everyone from novice users to experienced pros.
- FTP tips you might not know about
FTP is a necessity when transferring files to and from the iSeries. Site expert Tim Granatir provides a collection of miscellaneous FTP tips that address such subjects as the batch FTP process, logging FTP results to a file and getting to the Integrated File System. Check them out and see if there's anything you can add to your bag of tricks.
- Webcast: iSeries FTP automation made easy
How do you automate an FTP function? How do you go about creating a process to transfer a different file every day to different systems, the same file to different destinations or a combination of both? Thibault Dambrine shows you how easy it can be.