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

Transfer save file from remote IBM i to local IBM i using FTP?
Transfer save file from remote IBM i  to local IBM i using FTP?,ftp, file transfer protocol, as400 ftp, ibmi ftp, ibmi ftp commands, ibmi ftp local system commands, syscmd, save file, ibmi syscmd, ftp syscmd, (replace, ftp client subcomamnd,bin,get,crtsavf,loopback,as400,ibmi, as400andsqltricks, iseries,systemi
Transfer save file from remote IBM i  to local IBM i using FTP?

FTP when Target save file does not exist

In this example we will transfer the save file from remote IBM i (AS400) system to local IBM i (AS400) system using FTP and consider the save file does not exists on the local 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 GET command as below to get save file from remote IBM i (AS400) to local 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

    get /QSYS.LIB/FROMLIB.LIB/FROMSAVF.SAVF /QSYS.LIB/TOLIB.LIB/TOSAVF.SAVF (REPLACE

    We use FTP client subcommand option (replace to write over the loacal file if it already exists. The server does not overwrite the local file until and unless we specify (replace.

    > get /QSYS.LIB/easyclass1.LIB/testsav2.SAVF /QSYS.LIB/easyclass2.LIB/testsav3.SAVF (REPLACE 
      229 Entering Extended Passive Mode (!!!44607!).                                   
      150 Retrieving member TESTSAV2 in file TESTSAV2 in library EASYCLASS1.            
      226 File transfer completed successfully.                                         
      164736 bytes transferred in 0.085 seconds. Transfer rate 1938.962 KB/sec.
  • Finally QUIT FTP seession.
  • QUIT
  • Check whether save file created and transferred.
  • DSPSAVF easyclass2/testsav3
                                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 SYSCMD local system command and FTP

    In this example we will transfer the save file from remote IBM i (AS400) system to local IBM i (AS400) system using FTP and and will be creating the save file using SYSCMD local system command on local 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 SYSCMD local IBM i command.
  • We are using SYSCMD command here to create a save file on local IBM i (AS400) machine. The SYSCMD IBM i FTP client subcommand allows us to run a CL command on our local system without leaving the FTP environment. The following syntax for SYSCMD command:

    SYSCMD (Pass a CL Command to Your Local System)

    In our case we execute, CRTSAVF command whose syntax as follows:

    syscmd  CRTSAVF FILE(TO_Library/TO_SaveFile) 
    > syscmd  CRTSAVF FILE(easyclass2/testsav4)
  • Set the binary mode before transfer
  • > bin                                       
      200 Representation type is binary IMAGE.  
  • Get the save file from remote IBM i (AS400) to local IBM i (AS400).
  • We use FTP client subcommand option (replace to write over the loacal file if it already exists. The server does not overwrite the local file until and unless we specify (replace.

    get FROM_LIBRARY/FROM_SAVEFILE TO_LIBRARY/TO_SAVEFILE (REPLACE
  • Finally QUIT FTP seession.
  • QUIT

    Post a Comment

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