As long as personal computers and IBM midrange systems have coexisted in the business world, there has been a need to transfer files. Ever since personal computers were first introduced, end-users, impressed by the power the PC put at their fingertips, have longed to access the golden nuggets of information stored in midrange boxes. One phrase resounded inside their heads: Think of all the slicing and dicing that I could do!
Unfortunately, the treasured data seemed forever locked away in the midrange box, doled out only grudgingly by a back-logged MIS department. Data was usually delivered in the form of paper reports that had to be retyped into the PC.
Then IBM came to the rescue with a product called PC Support (now known as Client Access/400), which provided a link between the personal computer and the IBM midrange computer. Files could now be downloaded to a PC, where the end users could fiddle with them to their hearts content. All was right with the world.
A lot has happened since those early days of file transfer. Client/server technology has opened a whole new world of interaction between the PC and the AS/400, but there are still many situations in which a good old-fashioned file download fits the bill.
FTP versus Client Access Download
I have long relied on Client Access/400s download function whenever I needed to transfer a file from the AS/400 to a PC. Then, a scenario arose in which I had to use the File Transfer Protocol (FTP) command included in AS/400 TCP/IP. I was pleased to find that this method had several advantages over Client Access/ 400 download:
SpeedFTP is much faster than traditional downloads.
Cross-platform InteroperabilityFiles may be transferred to DOS, Windows, Macintosh, Unix, OS/2, or even other AS/400 systems.
No Router Program NeededClient Access/400 downloads require a router program to be loaded. FTP does not rely on a router program, which can lose connection to the AS/400 if the system is taken down.
What is FTP?
FTP is a program that was first developed in the early 1970s for transferring files on the Internet and implemented on host computers at the Massachusetts Institute of Technology. It has undergone many changes since that time, and today it is the predominant method for Internet file transfer.
In an FTP session, there is an FTP server and an FTP client. Once a session is established, the client can transfer files to and from the host. (Actually there are two connections established between the client and the host, one to request services from the server via subcommands and one to actually transfer data.)
FTP on the AS/400
In order to use the AS/400 FTP application, TCP/IP must be configured for your AS/400. This article will not go into the specifics of configuring TCP/IP, but thorough instructions and an explanation of TCP/IP networks is contained in the IBM manual AS/400 TCP/IP Configuration and Reference (SC41-3420-00).
The AS/400 can be used as either an FTP client or server, but we will focus on using the AS/400 as an FTP client.
Before you can transfer files with an FTP server, you must first know the name or IP address of the server and a user ID and password (if required). Many universities, government agencies, companies, and private individuals have set up publicly accessible anonymous FTP servers that do not require a user ID or password. FTP server software must be running on the remote system.
The FTP client program is started on the AS/400 by entering either FTP or STRTCPFTP (Start TCP/IP File Transfer) at the command line. Pressing F4 to display the command parameters will present the display in Figure 1.
Lets take a brief look at the parameters:
Remote SystemThis can either be the name of the FTP server or *INTNETADR if you are specifying an Internet address. If you frequently connect to the same server, the server name can be entered into the TCP/IP host table with the Add TCP/IP Host Table Entry (ADDTCPHTE) command. You can then use the server name in the FTP command, and it will not be necessary to remember the Internet address.
Internet AddressThis parameter is used if *INTNETADR is entered for the Remote system parameter. The Internet address is usually four groups of numbers separated by periods.
Coded Character Set IdentifierThis is the number of the character set used when the transferred file is translated from EBCDIC to ASCII. *DFT specifies the default character set (ISO 8859-1 8-bit ASCII).
Outgoing EBCDIC/ASCII Table/ Library and Incoming ASCII/ EBCDIC Table/LibraryThese parameters are used if you are using a custom table for translating the files to or from ASCII and EBCDIC. The tables tell FTP to translate a specific character on the host system to another specific character on the target system. (For instance, you could tell FTP to make all double quotes in the AS/400 source file into single quotes on the target file.) The default of *CCSID is usually sufficient.
When you press the Enter key, a connection is established with the remote FTP server. You will be prompted to enter the user ID and password, if required. You will
then be presented with a command line on which you can issue FTP subcommands to the remote server.
You will need to understand some of the more commonly used FTP subcommands and their meanings:
OPENConnect to another FTP server from within an FTP session.
CLOSEDisconnect from an FTP server from within an FTP session (without ending the session).
QUITDisconnect from all connected FTP servers and end the FTP session.
PUTTransfer a file from the AS/400 client to the FTP server. This subcommand is in the format:
PUT library/file.member target file name
GETRetrieve a file from the remote server to the AS/400 client.
CDChange the current directory on the remote FTP server.
DIRList the files in the current directory of the remote FTP server.
USERSend your user ID (logon) to the remote FTP server.
PWDSend your password to the remote FTP server.
EBCDICChanges the default transfer type from ASCII to EBCDIC. This is useful when transferring files from one AS/400 to another.
A complete list of FTP subcommands can be viewed by keying HELP on the FTP command line. Help text for a particular subcommand can be viewed by typing a question mark (?) followed by the subcommand on the FTP command line.
FTP takes care of all character translation for the transferred files. AS/400 files transferred to a remote PC are translated to nondelimited ASCII files.
Running FTP in Batch
In addition to running in an interactive session, FTP can also be run in a batch session. When running an FTP batch session, commands are read from an AS/400 source file. The results of each command to the remote system are also logged to a file that can be scanned for errors. Figure 2 is an example of a source file containing FTP subcommands for a batch session.
Following is a brief explanation of the file:
0001.00This line contains the user ID (logon) and password for the remote FTP server.
0002.00This line contains the command to transfer the file called MYFILE in library QGPL to file MYFILE on the remote server.
0003.00This line ends the FTP batch session and disconnects from the remote server.
A CL program can now be created to run the commands in our example source file member. Figure 3 shows an example of a CL program which will process our source file.
Here are the details of the CL program that will process our source file, shown Figure 3:
0002.00The OVRDBF commands overrides the FTP input file to our source file shown in Figure 2.
0003.00The OUTPUT source file member FTPLOG contains the logged messages from our batch FTP session.
0004.00The FTP command establishes a connection with the remote FTP server.
After the program is run, source file member FTPLOG will contain the logged messages from the FTP session. Figure 4 show an example of an FTP log file from our batch session.
If you have a need to schedule file transfers to run unattended, the FTP CL program can be submitted to a job queue to run at a scheduled date and time.
In todays world, the need to communicate and transfer files between diverse systems is steadily growing. The FTP file transfer application, that workhorse of the Internet, provides an easy, dependable method for filling that need.
Figure 1: Starting FTP with STRTCPFTP Command Figure 2: Sample FTP Source Figure 3: CL Program to Process FTP Source
Figure 4: FTP Log File
LATEST COMMENTS
MC Press Online