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.
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
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.
QUIT
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.
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 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.
> bin 200 Representation type is binary IMAGE.
put FROM_LIBRARY/FROM_SAVEFILE TO_LIBRARY/TO_SAVEFILE
QUIT