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.
FTP loopback
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. ===>
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.
QUIT
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.
FTP loopback
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.
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)
> bin 200 Representation type is binary IMAGE.
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
QUIT