In my last tech tip, "Tricks and techniques for FTPing OS/400 save files," I explained some of the ins and outs...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
of using PUT to FTP save files from one iSeries or AS/400 to another. I received a lot of e-mail on that tip, giving me additional information on these techniques and correcting some information about the process. This time around, let's use some of your feedback to go even deeper into FTPing save files from one iSeries to another.
1. FTP goes in two directions
Several readers mentioned that you can also retrieve save files to your FTP client by using the FTP GET sub-command, which I didn't have space to include in the last tip. Where PUT transfers files upstream (from the FTP client to the attached FTP server), GET transfers them downstream (from the server to the client). Many of the same rules I discussed with PUT apply to GET, but GET has an optional parameter to automatically clear out an existing target file on your iSeries FTP client machine. Here's an example a reader sent me that clears and transfers a standard OS/400 physical file to another iSeries:
BIN NAMEFMT 0 GET TECHTARGET/JOE TECHTARGET/JOE (REPLACE
In this example, we're explicitly using Name Format 0 -- where OS/400 libraries and objects are defined in a library/filename format -- to transfer a physical file called joe in library techtarget from the FTP server iSeries to the same library on the FTP client iSeries. Also notice the '(REPLACE' parameter at the end of the command (and yes, it is coded with only a left parenthesis). Unlike PUT, OS/400 GET uses this optional replacement parameter to tell FTP to automatically write over your local file on the client if it already exists. If you add '(REPLACE' to the GET string, the target file will be overwritten. If you don't add it and a file already exists, you will receive a message saying the file already exists and the transfer will not complete. It's also worth mentioning that GET creates the file on your FTP client if it doesn't exist.
This NAMEFMT 0 technique also works for FTPing save files between two iSeries machines, provided the target save file already exists on your FTP client iSeries. If it does, OS/400 will clear the target save file and transfer all of your save file information. You don't need to do any pre-clearing of the save file. However, in my testing of this technique between two V4R5 machines, I found that if the target save file doesn't already exist on your FTP client, OS/400 FTP will not transfer your save file correctly to the target machine. FTP will mark the newly created target file as a physical file, not as a save file. So having the target save file exist on your FTP client machine prior to a GET transfer is crucial to this technique.
To use GET for save file transfers when the Name Format parameter equals 1 -- where OS/400 file names are defined in the Integrated File System (IFS) format -- you would then modify your FTP sub-commands to use IFS style names, as follows:
BIN NAMEFMT 1 GET /QSYS.LIB/TECHTARGET.LIB/JOE.SAVF /QSYS.LIB/TECHTARGET.LIB/JOE.SAVF (REPLACE
In this case, we have to flag the file name with a .SAVF extension for the transfer to complete successfully.
2. PUT doesn't necessarily need an empty target save file
In the last tip, I wrote that when using the PUT sub-command to transfer save files in a NAMEFMT 0 session, the target save file needs to be empty for the transfer to succeed. Several readers wrote me back saying that this wasn't necessarily the case, and that they frequently transfer FTP files using PUT without first clearing out the target save file on their iSeries FTP servers. From long years of using FTP, I always make sure to clear the save file first out of habit -- and because I prefer to leave nothing to chance. Clearing target save files is also something of an informal FTP convention in certain areas, and this specification has been published in several iSeries FTP articles.
With this reader feedback, however, I retested a NAMEFMT 0 PUT sub-command without clearing the target save file, and I found that it did indeed clear the target save file and transfer the file correctly. So I stand corrected. You may want to try skipping the Clear Save File step in my previous tip, but if you run into problems receiving your data correctly, you can then try clearing out the target save file first to see if that helps the situation. You can also use the Name Format 1 technique I listed in my first tip to create the save file on your target system.
3. It may not be necessary to specify Name Format 1 when transferring files in Integrated File System (IFS) notation
Another reader pointed out that it's not necessary to specify NAMEFMT 1 when using IFS naming conventions to transfer a save file. He said OS/400 will automatically specify NAMEFMT 1 whenever you use IFS naming formats in your FTP sub-commands, and that generally, whenever you precede the file name in a GET, PUT, MGET, or MPUT sub-command with a slash (/), FTP will automatically set your session to NAMEFMT 1.
Other people have told me this, as well, but I've never been able to get it to work in a production environment. As a result, I always explicitly specify NAMEFMT 1 when I'm transferring files from the IFS. However, since others have said that it works, I can only speculate that this is a "your mileage may vary" (YMMV) situation. OS/400 FTP may automatically switch to a NAMEFMT 1 session whenever you use IFS naming conventions. If it doesn't, however, be sure to explicitly execute the NAMEFMT 1 sub-command. At the very least, specifying NAMEFMT 1 couldn't hurt, and it's one fewer thing to leave to chance.
As you can see, FTP isn't quite an exact science and there is room for different ways for transferring files. The FTP techniques you choose depend on your own comfort level and the amount of knowledge you possess. And these simple FTP tricks should be helpful as you're move large save files between AS/400s.
About the author: Joe Hertvik is an IT professional and freelance writer who has been working with OS/400 since the days of the System/38 in the mid-1980s. Joe can be reached at email@example.com.
- AUTOFTP reduces security exposure found in traditional FTP transfers
Search400 member Philip Howells has created a command called AUTOFTP that can reduce the main security exposure otherwise present when simply batching together FTP scripts (FTP input read by a CL). The command allows the processing of FTP input scripts to be further automated and scheduled (without the standard AS/400 scheduler) and provides a number of clear benefits.
- Sending *SAVF using e-mail attachment
Try this techniques if you have a problem sending objects to another iSeries.
- .snSEamCCeaq^0@.ee84639>Managing the iSeries Discussion Forum: Post your questions, and get answers from other iSeries systems managers and administrators as well as search400 experts.
- Search400's Best Web Links on Systems Management