Batch FTP in IBM i(AS400)

Batch FTP in IBM i(AS400)
Batch FTP in IBM i(AS400), batch ftp in as400,Running File Transfer Protocol in unattended mode using a batch job,FTP client in an unattended mode,Simple example of batch ftp, File Transfer Protocol, ftp, transferring file to a remote host, FTP subcommands file, The output messages file,The input commands file,The CL program, OVRDBF, FTP RMTSYS, loopback, quit, bin, namefmt 1, put, ibmi, as400, clle, cl as400, ibmi tutorial, as400 tutorial, ftp tutorial, as400 and sql tricks
Batch FTP in IBM i(AS400)

We can run FTP client interactively and in batch i.e. unattended mode.

Components involved in batch FTP

  1. A CL program
  2. An Input file of FTP commands
  3. An Output file of FTP messages

Simple Example using Batch FTP

The example below shows a batch file transfer that involves the successful transfer of one file to the remote system.

A CL program

             PGM                                                      
             OVRDBF     FILE(INPUT) TOFILE(EASYCLASS1/FTP) +          
                          MBR(INPUT) OVRSCOPE(*CALLLVL)               
             OVRDBF     FILE(OUTPUT) TOFILE(EASYCLASS1/FTP) +         
                          MBR(OUTPUT) OVRSCOPE(*CALLLVL)              
             FTP        RMTSYS(LOOPBACK)  
             DLTOVR     FILE(INPUT OUTPUT)    
             ENDPGM                                                   

This CL program overrides the INPUT parameter to the source physical file EASYCLASS1/FTP, member INPUT and the OUTPUR parameter to the source physical file EASYCLASS1/FTP, member OUTPUT. The output of the FTP logs would be added to the member OUTPUT. Finally, delete the overrides.

Note: Please note that in FTP command parameter RMTSYS, please replace loopbck with remote address. For now, in place of remote system ip/domain we provide the loopback since, we do not have remote machine available and we will test the batch FTP using the same machine. Therefore, using loopback mechanism the same machine will be our remote machine.

Create the CLLE program using option 14 on the source member or by running command CRTBNDCL.

An Input file of FTP commands

The FTP subcommands required to perform FTP would be listed in this INPUT file. This is a file so no need to compile this member.

UserId password                                                                           
bin                                                                                           
namefmt 1                                                                                     
PUT /QSYS.LIB/EASYCLASS1.LIB/ifs.file/access.mbr /QSYS.LIB/EASYCLASS1.LIB/ftp.file/access.mbr 
QUIT

Note: Please replace UserId and password with your actual userid and password of the remote machine.

Here, we will transfer source file member access in EASYCLASS1/IFS source file location to the source file location EASYCLASS1/FTP.

An Output file of FTP messages

The OUTPUT file of FTP messages would be blank file initially and once we execute batch FTP program the ftp logs(successful +error FTp messages) gets added to this OUTPUT file. This is a file so need to compile this member.

The data that will be added by the program in this output file of ftp messages in the following format.

Source members involved in batch FTP

                           Work with Members Using PDM         
                                                               
 File  . . . . . .   FTP                                       
   Library . . . .     EASYCLASS1           Position to  . . . 
                                                               
 Type options, press Enter.                                    
  2=Edit         3=Copy  4=Delete 5=Display       6=Print     7
  8=Display description  9=Save  13=Change text  14=Compile  15
                                                               
 Opt  Member      Type        Text                             
      FTP_BCH     CLLE        Batch Ftp                        
      INPUT       CLLE        Ftp commands                     
      OUTPUT      CLLE        Ftp log output generated here

Execute Batch FTP program FTP_BCH

Let's execute batch FTp program named "FTP_BCH" from IBM i command line using command CALL FTP_BCH.

Output of batch FTP program

The output FTP messages will be logged in OUTPUT file and the source member gets ftped successfully.

The output messages file: (OUTPUT source member file in source file location EASYCALSS1/FTP)

Output redirected to a file.                                                 
Input read from specified override file.                                     
Connecting to host LOOPBACK at address 127.0.0.1 using port 21.              
220-QTCP at LOOPBACK.                                                        
220 Connection will close if idle more than 1666 minutes.                    
Enter login ID (easyclass):                                                  
331 Enter password.                                                          
230 EASYCLASS logged on.                                                     
 OS/400 is the remote operating system. The TCP/IP version is "V7R5M0".      
250  Now using naming format "1".                                            
257 "/home/EASYCLASS" is current directory.                                  
Enter an FTP subcommand.                                                     
> bin                                                                        
200 Representation type is binary IMAGE.                                     
Enter an FTP subcommand.                                                     
> namefmt 1                                                                  
250  Now using naming format "1".                                            
Server NAMEFMT is 1.                                                         
Client NAMEFMT is 1.                                                         
Enter an FTP subcommand.                                                                       
> PUT /QSYS.LIB/EASYCLASS1.LIB/ifs.file/access.mbr /QSYS.LIB/EASYCLASS1.LIB/ftp.file/access.mbr
229 Entering Extended Passive Mode (|||12375|).                                                
150 Sending file to member ACCESS in file FTP in library EASYCLASS1.                           
226 File transfer completed successfully.                                                      
  6500 bytes transferred in 0.001 seconds. Transfer rate 6656.000 KB/sec.                      
Enter an FTP subcommand.                                                                       
> QUIT                                                                                         
221 QUIT subcommand received.

source member FTPed successfully

                          Work with Members Using PDM            
                                                                 
File  . . . . . .   FTP                                          
  Library . . . .     EASYCLASS1           Position to  . . . . .
                                                                 
Type options, press Enter.                                       
 2=Edit         3=Copy  4=Delete 5=Display       6=Print     7=Re
 8=Display description  9=Save  13=Change text  14=Compile  15=Cr
                                                                 
Opt  Member      Type        Text                                
     ACCESS                                                      
     FTP_BCH     CLLE        Batch Ftp                           
     INPUT       CLLE        Ftp commands                        
     OUTPUT      CLLE        Ftp log output generated here

Post a Comment

© AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain