FTP is a necessity when transferring files to and from the iSeries. This week site expert Tim Granatir provides...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
a collection of miscellaneous FTP tips that address such subjects as the batch FTP process, logging FTP results to a file and getting to the Integrated File System. Check them out and see if there's anything you can add to your bag of tricks.
1. Example of transferring a file to an iSeries without having to create the save file on the target iSeries
FTP 'xxx.xxx.xxx.xxx' sign in with a valid password and user ID. BINARY NAMEFMT 1 PUT /qsys.lib/fromlib.lib/fromsavef.savf /qsys.lib/tolib.lib/tosavef.savf QUIT
You always need to use binary when transferring save files but the real key here is the use of the NAMEFMT 1 command. When you use NAMEFMT 1, you will need to specify your file names in the same way that you would if you were using the IFS.
2. Batch FTP process from the iSeries
This is similar to the DOS batch file approach but just slightly different.
Here is the example code for the CL program on the iSeries:
PGM /* FTP COMMANDS FILE */ OVRDBF FILE(INPUT) TOFILE(MYLIB/QTXTSRC) MBR(INPUT) FTP RMTSYS('xxx.xxx.xxx.xxx') ENDPGM
Here is the example for the Input file:
MYUSER MYPASSWORD PUT MYLIB/MYFILE QUIT
If you override the file INPUT before the FTP command, FTP will use the file you specified for your FTP commands. The file containing your FTP commands can either be a source file or a physical file.
3. Logging FTP results to a file
If you override the file OUTPUT before doing your FTP command, your FTP commands and results will be logged to the file you specified.
Ex. OVRDBF FILE(OUTPUT) TOFILE(MYLIB/FTPLOG) MBR(FTPLOG)
4. Running system commands on a remote iSeries
Using the SYSCMD function in FTP allows you to run system commands on the remote system.
From a non-iSeries -- quote rcmd sndmsg msg(hello) tousr(myuser)
From iSeries to iSeries -- syscmd sndmsg msg(hello) tousr(myuser)
5. Increasing the amount of time before a connection automatically closes
Quote time 1000 -- Increases idle time to 1000 seconds
By default, FTP automatically disconnects after five minutes of inactivity. This will increase that amount of time.
6. Getting to the Integrated File System
After you make your FTP connection to the 400, go to the root directory and add your directories as needed. Example:
cd / cd qdls cd
When you switch to the root directly, make sure you use a forward slash instead of a back slash. Also, when you change to the root directory, OS/400 changes the NAMEFMT to 1 for you.
7. FTP DOS extensions
I have used some of these extensions but not all of them. This is a useful reference if you need to do any DOS batch files with FTP.
- -v suppress display of remote server processes
- -n suppress auto log in upon initial connection
- -i turns off interactive prompting during multiple file transfers
- -d enables debugging
- -a allows the use any local interface when binding data connection
- -A is for "anonymous" log in
- -w:buffersize overrides the default transfer buffer size of 4096
- host = specifies the host name or IP address of the remote host to connect to
- -s:filename specifies a text file containing FTP commands
About the author: Tim is vice president of Technical Services at Interlink Technologies in Maumee, Ohio, where he serves as chief architect for their warehouse management system. He has worked in the banking, insurance, healthcare and distribution industries in various positions, including programmer/analyst, systems analyst and DP manager. Tim has worked on IBM midrange platforms since 1983.
- FTP: You wish to remain anonymous?
Anonymous FTP was created to satisfy the demand of FTP-TCP/IP users all over the Internet to send and receive files of a public domain or publicly available nature. As you can imagine, with that amount of data available for FTP transfer, it was and is simply impossible to set-up user accounts and passwords for every user on every FTP server on the Internet. Follow Kris Neely's guidelines for using this feature.
- Tricks and techniques for FTPing OS/400 save files
Save files (SAVF) are great for transferring iSeries and AS/400 objects between OS/400-based machines. Whether it's a group PTF, a file, a library or even a licensed program, save files can quickly zip large amounts of information between two AS/400s, especially if the save files are transmitted via FTP. Unfortunately, there's a bit of misunderstanding about how to properly FTP save files between two AS/400s. There are a few simple, but hard-fast, rules that users must follow to successfully transfer save files.
- Batch FTP using IIS
Search400.com member Shawn Hunt says he's been using this technique for a while, and it is much easier than creating a file transfer or anything of that sort.