Return to the FTP Tips
Batch FTP Between AS/400s
To initiate an automatic batch FTP transfer from an AS/400, first create a script in a source physical file containing valid FTP commands. To get it to work in batch (that is, without user input) when you run the FTP session, you must create a file override on a file called INPUT that tells the AS/400's FTP client where to retrieve the commands from (instead of from the keyboard, as it normally would). Thus, you override INPUT to point to your FTP script. If you want to capture the FTP session's results, you also must override a file called OUTPUT to a member where the session will be logged.
For example, to transfer member HISMBR in file HISFILE in HISLIB from remote AS/400 HISAS400 to member MYMBR in file MYFILE in library MYLIB on MYAS400, use the following script, which I've named FTPCMDS in the source file FTPSRC on the AS/400 originating the FTP session (MYAS400):
MYUSER PASSIT GET HISLIB/HISFILE.HISMBR MYLIB/MYFILE.MYMBR QUITThis script works for source file members. To use the script, start the FTP server on the remote system (HISAS400) with the command STRTCPSVR *FTP. Then, execute the following CL program on the source system (MYAS400):
PGM OVRDBF FILE(INPUT) TOFILE(FTPSRC) MBR(FTPCMDS) CLRPFM FTPSRC/OUT OVRDBF FILE(OUTPUT) TOFILE(FTPSRC) MBR(OUT) FTP HISAS400 ENDPGMFor this CL program to work, you must create a member called OUT in the FTPSRC file, which will contain the responses from the remote AS/400. Look in this member for any messages for debugging/error checking.
Note that the user ID and password must be stored in the FTP command source member, so be sure to secure that member appropriately.
[report a broken link by clicking here]