You are on page 1of 2

AS400 Batch FTP Example

Batch FTP: A Simple Example

The following is a simple example of a batch file transfer involving the successful
transfer of one file from a remote system and the unsuccessful transfer of one file
from a remote system.

The components are as follows:


o The CL program.
o The Input Commands File (an input file of FTP commands, MAX record length of
2000) - member type should be TXT.
o The Output Messages File (an output file of FTP messages) - member type
should be TXT.

The CL Program

************************************************************
ITSOLIB2/QCLSRC BATCHFTP:
----------------------
PGM
OVRDBF FILE(INPUT) TOFILE(ITSOLIB2/QCLSRC) MBR(FTPCMDS)
OVRDBF FILE(OUTPUT) TOFILE(ITSOLIB2/QCLSRC) MBR(OUT)
FTP RMTSYS(SYSxxx)
ENDPGM
************************************************************

The BATCHFTP program overrides the INPUT parameter to the source physical file
ITSOLIB2/QCLSRC MBR(FTPCMDS). The output is sent to MBR(OUT).

The Input Commands File (member type should be TXT)

************************************************************
ITSOLIB2/QCLSRC FTPCMDS:
---------------------
ITSO ITSO
CD ITSOLIB1
SYSCMD CHGCURLIB ITSOLIB2
GET QCLSRC.BATCHFTP QCLSRC.BATCHFTP (REPLACE
QUIT
************************************************************

The FTP subcommands required are shown in the FTPCMDS file.

The Output Messages File (member type should be TXT)

************************************************************
FTP Output Redirected to a File
FTP Input from Overridden File
Connecting to host name SYSxxx
at address x.xxx.xx.xxx using port 21.
220-QTCP at SYSxxx.rchland.ibm.com.
220 Connection will close if idle more than 5 minutes.
215 OS/400 is the remote operating system.
The TCP/IP version is "V3R1M0"
Enter login ID (itso):
> ITSO ITSO
331 Enter password.
230 ITSO logged on.
250 Now using naming format "0".
257 "QGPL" is current library.
Enter an FTP subcommand.
> CD ITSOLIB1
Enter an FTP subcommand.
250 Current library changed to ITSOLIB1.
> SYSCMD CHGCURLIB ITSOLIB2
Enter an FTP subcommand.
> GET QCLSRC.BATCHFTP QCLSRC.BATCHFTP (REPLACE
200 PORT subcommand request successful.
150 Retrieving member BATCHFTP in file QCLSRC in library ITSOLIB1.
250 File transfer completed successfully.
147 bytes transferred in 0.487 seconds. Transfer rate 0.302 KB/sec.
Enter an FTP subcommand.
> QUIT
221 QUIT subcommand received.
************************************************************

You might also like