Example: Creating a CL program to start FTP

This is an example CL program to start File Transfer Protocol (FTP) in batch mode. The CL program contains commands to override the command input and message output, start the FTP, and delete the overrides when the FTP is closed.

  1. As shown in the simple example, FTP uses the display station for command INPUT and message OUTPUT, and this needs to be overridden for use in batch mode. In this example, the OVRDBF command is used to overwrite these files with the ones to be used in batch:
               OVRDBF FILE(INPUT) TOFILE(GERRYLIB/QCLSRC) MBR(FTPCMDS) 
               OVRDBF FILE(OUTPUT) TOFILE(GERRYLIB/QCLSRC) MBR(FTPLOG) 
    
  2. A host name or an Internet address is a required parameter for the STRTCPFTP command that is included in the CL program file. However, if you want to specify the remote systems in the input commands file instead of the CL program file, you must specify a dummy host name for the STRTCPFTP command to satisfy the required syntax. This dummy name can be a fictitious host name or a real host name. If it is a real name, then the first entry in the input commands file must be a user ID and a password, and the second entry must be the CLOSE subcommand. If it is not a real host name, these entries are not required, and the first entry must be an OPEN subcommand to connect to the required FTP server.
                 FTP RMTSYS(LOOPBACK) 
    
    FTP processes the input file and writes messages to the output file (FTPLOG).
  3. After the FTP application ends, delete the overrides:
                 DLTOVR     FILE(INPUT OUTPUT) 
    

    The CL program for batch FTP will look like the following example, in Figure 1, on system SYSNAM01:

    Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
    Figure 1. CL program FTPBATCH for batch FTP
    
                                                                                          
                                                                                          
         Columns . . . :    1  71           Browse                      GERRYLIB/QCLSRC   
         SEU==>                                                                FTPBATCH   
         FMT **  ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7    
                *************** Beginning of data *************************************   
        0001.00 PGM                                                                       
        0002.00              OVRDBF     FILE(INPUT) TOFILE(GERRYLIB/QCLSRC) +             
        0003.00                           MBR(FTPCMDS)                                    
        0004.00              OVRDBF     FILE(OUTPUT) TOFILE(GERRYLIB/QCLSRC) +            
        0005.00                           MBR(FTPLOG)                                     
        0006.00              FTP        RMTSYS(LOOPBACK) /* (FTP CL Program) */           
        0007.00              DLTOVR     FILE(INPUT OUTPUT)                                
        0008.00 ENDPGM                                                                    
                ****************** End of data ****************************************   
                                                                                          
                                                                                          
         F3=Exit   F5=Refresh   F9=Retrieve   F10=Cursor   F12=Cance                      
         F16=Repeat find        F24=More keys                                             
                                                 (C) COPYRIGHT IBM CORP. 1981, 1994.