Now, Get RPG Codes in all three formats only on this website on every RPGLE related programming article.

Fixed, /Free and Fully Free RPG


Transfer save file from local IBM i to remote IBM i using FTP?

Transfer save file from local IBM i to remote IBM i using FTP?
Transfer save file from local IBM i to remote IBM i using FTP?,ftp, file transfer protocol, as400 ftp, ibmi ftp, ibmi ftp commands, ibmi ftp remote commands, IBmi QUOTE command, IBmi rcmd command,bin,put,crtsavf,loopback,as400,ibmi, as400andsqltricks, iseries,systemi
Transfer save file from local IBM i to remote IBM i using FTP?

FTP when Target save file does not exist

In this example we will transfer the save file from local IBM i (AS400) system to remote IBM i (AS400) system using FTP and consider the save file does not exists on the remote IBM i (AS400) system.

Here we do not have a remote machine available therefore for demo we will be using the same machine as remote machine using loopback mechanism. You may use the remote host ip address in place of loopback.

Transfer save file from From_Library/From_SaveFile to To_Library/To_SaveFile.

  • From IBM i command line, Type FTP hostname(domain name/ip address) i.e. hostname is loopback here since we do not have remote IBM i (AS400) machine avaible for now.
  • FTP loopback
  • FTP session is opened, Enter user id and password of the remote host machine and once login then Type NAMEFMT1 for name format *PATH to access the files in the IFS and press Enter and Type bin for transferring binary image and press Enter.
  •                                                       File Transfer Protocol 
                                                                                 
    Previous FTP subcommands and messages:                                       
      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.                  
    > easyclass                                                                  
      331 Enter password.                                                        
      230 EASYCLASS logged on.                                                   
       OS/400 is the remote operating system. The TCP/IP version is "V7R4M0".    
      250  Now using naming format "1".                                          
      257 "/home/EASYCLASS" is current directory.                                
    > namefmt 1                                                                  
      250  Now using naming format "1".                                          
      Server NAMEFMT is 1.                                                       
      Client NAMEFMT is 1.                                                       
    > bin                                                                        
      200 Representation type is binary IMAGE.                                   
                                                                                 
    Enter an FTP subcommand.                                                     
    ===>                                                                         
  • Use PUT command as below to put save file from local IBM i (AS400) to remote IBM i (AS400)
  • Since NAMEFMT 1 was used which used IFS to access save file. Therefore, we need to browse the fully qualified path for from and to save file in fromlib and tolib libarry with QSYS library

    put /QSYS.LIB/FROMLIB.LIB/FROMSAVF.SAVF /QSYS.LIB/TOLIB.LIB/TOSAVF.SAVF
     put /QSYS.LIB/easyclass1.LIB/testsav2.SAVF /QSYS.LIB/easyclass2.LIB/testsav2.SAVF 
      229 Entering Extended Passive Mode (!!!28860!).                                   
      150 Sending file to member TESTSAV2 in file TESTSAV2 in library EASYCLASS2.       
      226 File transfer completed successfully.                                         
      164736 bytes transferred in 0.023 seconds. Transfer rate 7028.736 KB/sec.         
    Enter an FTP subcommand.
  • Finally QUIT FTP seession.
  • QUIT
  • Check whether save file created and transferred.
  • DSPSAVF easyclass2/testsav2
                                 Display Saved Objects                    
                                                                          
     Library saved . . . . . . . :   EASYCLASS1                           
                                                                          
     Type Options, press Enter.                                           
       5=Display                                                          
                                                                          
     Opt  Object      Type      Attribute   Owner          Size (K)  Data 
          EXTPGM5     *PGM      RPGLE       EASYCLASS           136  YES  

    Creating the save file using remote command and FTP

    In this example we will transfer the save file from local IBM i (AS400) system to remote IBM i (AS400) system using FTP and and will be creating the save file using remote command on remote IBM i(AS400) machine and we will not use NAMEFMT 1 name format this time.

    Here we do not have a remote machine available therefore for demo we will be using the same machine as remote machine using loopback mechanism. You may use the remote host ip address in place of loopback.

    Transfer save file from From_Library/From_SaveFile to To_Library/To_SaveFile.

  • From IBM i command line, Type FTP hostname(domain name/ip address) i.e. hostname is loopback here since we do not have remote IBM i (AS400) machine avaible for now.
  • FTP loopback
  • FTP session is opened, Enter user id and password of the remote host machine and login to remote machine.
  •                                                       File Transfer Protocol 
                                                                                 
    Previous FTP subcommands and messages:                                       
      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.                  
    > easyclass                                                                  
      331 Enter password.                                                        
      230 EASYCLASS logged on.                                                   
       OS/400 is the remote operating system. The TCP/IP version is "V7R4M0".    
      250  Now using naming format "1".                                          
      257 "/home/EASYCLASS" is current directory.
  • Create a save file using remote command.
  • We are using QUOTE command here to create a save file on remote IBM i (AS400) machine. This QUOTE IBM i FTP client subcommand will send a subcommand to an FTP server. The client has to run the QUOTE subcommand to run the special IBM i FTP server subcommand RCMD (Send a CL Command to an FTP Server System).

    quote rcmd CRTSAVF File(TO_LIBRARY/TO_SAVFILE)
    > quote rcmd CRTSAVF File(EASYCLASS2/TESTSAV2)               
      250 Command CRTSAVF File(EASYCLASS2/TESTSAV2) successful.  
  • Set the binary mode before transfer
  • > bin                                       
      200 Representation type is binary IMAGE.  
  • Put the save file from local IBM i (AS400) to remote IBM i (AS400)
  • put FROM_LIBRARY/FROM_SAVEFILE TO_LIBRARY/TO_SAVEFILE
  • Finally QUIT FTP seession.
  • QUIT

    Post a Comment

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