21
Thu, Nov
1 New Articles

The AS/400 File Transfer Protocol

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Every AS/400 running V3R1 has TCP/IP built right into the operating system. This is also true for most other popular computer systems today, whether they're made by IBM or anyone else. TCP/IP has become the standard protocol for networking computers from multiple vendors.

TCP/IP has a common set of applications that allow you to communicate with other systems on a network (see "AS/400 Telnet," MC, September 1995). In this article, I'll discuss one of those applications?the AS/400's implementation of File Transfer Protocol (FTP).

FTP is an application that allows you to send and receive copies of files to or from one computer system to another. The main advantage of using FTP is that it is supported on a wide variety of platforms. So, for example, if you need to transfer files from an AS/400 to a UNIX system, FTP will get the job done.

On the AS/400, file transfers have traditionally been accomplished either with the Send Network File (SNDNETF) command over a SNADS network, or by using a PC application such as the Client Access File Transfer facility. However, many non-IBM systems don't cooperate with SNADS or Client Access. FTP can be used in place of either of these two methods to accomplish a similar task with a multitude of other systems?IBM and non-IBM. Let's briefly take a look at the pros and cons of using FTP on the AS/400.

Pros and Cons

You can use FTP to transfer object types other than files by saving them into a save file prior to transferring them. If the other system is an AS/400, you can restore the objects in the save file after the file transfer. However, even if the other system is not an AS/400, you can transfer data to and from save files, which isn't possible with Client Access (not directly anyway). So, for example, you could save an AS/400 program into a save file and use FTP to send the contents of the save file to a PC file. You could then give that PC file to someone who could use FTP to send it back to a save file on another AS/400. He would be able to restore the program to his system. No special programming is required to accomplish this. In addition to supporting save file data, FTP supports transferring documents, as well as files stored on optical drives.

The disadvantage of FTP is that it supports only minimal data type translation capabilities when sending files to a system other than an AS/400. For example, while it will translate data from EBCDIC to ASCII, it won't translate packed decimal fields to character data. If you need to transfer this type of data to anything except another AS/400, you'll need to write a program to convert the data into a format that the other system can recognize. FTP also won't allow you to perform any type of record selection, as is possible with Client Access File Transfer. You either have to transfer the entire file or nothing at all.

Now that you know what some of FTP's abilities and limitations are, let's take a closer look at the AS/400 implementation. There are two sides to the AS/400 FTP application. The FTP server handles requests from other systems, and the FTP client allows you to access files on other systems.

The FTP Server

Before using FTP on the AS/400 for the first time, you'll need a basic TCP/IP configuration as described in "Configuring TCP/IP on the AS/400," MC, August 1995. The TCP/IP Connectivity Utilities/400 licensed program, which is included with the base operating system at no extra charge, ships with FTP servers preconfigured. You can view or change the FTP server configuration by prompting the Change FTP Attributes (CHGFTPA) command, as shown in 1.

Before using FTP on the AS/400 for the first time, you'll need a basic TCP/IP configuration as described in "Configuring TCP/IP on the AS/400," MC, August 1995. The TCP/IP Connectivity Utilities/400 licensed program, which is included with the base operating system at no extra charge, ships with FTP servers preconfigured. You can view or change the FTP server configuration by prompting the Change FTP Attributes (CHGFTPA) command, as shown in Figure 1.

You'll probably want to leave most of the FTP attributes set to their default configurations. However, you may want to consider changing a couple of them. The Number of initial servers (NBRSRV) parameter defaults to 3. This number represents the number of FTP servers that start when either the Start TCP/IP (STRTCP) or Start TCP/IP Server (STRTCPSVR) command is run. Having multiple FTP server jobs running improves the performance of initiating an FTP session when multiple users attempt to connect at the same time. If you anticipate serving many FTP users, you may need to increase this value. The other parameter you may want to consider changing is Inactivity timeout (INACTTIMO). This value represents the number of seconds the system allows an FTP connection to remain inactive before it is ended. The default value is 300, which represents 5 minutes. If you're accessing your AS/400 through FTP and find that you're constantly receiving error messages that say your connection was closed by the remote host, you may want to consider increasing this value.

The FTP Servers need to be started before any other systems can make FTP requests. Normally, this happens automatically when you run the STRTCP command (unless you've changed the AUTOSTART parameter to *NO on the CHGFTPA command). You can verify that the FTP servers are active by looking for job names, starting with QTFTP in subsystem QSYSWRK. If you see these jobs, your system should be ready to accept FTP requests from an FTP client.

The FTP Client

You can use two commands to start the FTP client: either the FTP command or the Start TCP/IP FTP (STRTCPFTP) command. Both commands are identical. The FTP command has only one required parameter, as shown in 2. The Remote system (RMTSYS) parameter is where you enter the host name of the system you want to connect to. The host name can be defined in the Work with TCP/IP host table entries option on the Configure TCP/IP menu (GO CFGTCP). Alternatively, you can specify *INTNETADR for the host name and specify the IP address of the system you want to access in the INTNETADR parameter.

You can use two commands to start the FTP client: either the FTP command or the Start TCP/IP FTP (STRTCPFTP) command. Both commands are identical. The FTP command has only one required parameter, as shown in Figure 2. The Remote system (RMTSYS) parameter is where you enter the host name of the system you want to connect to. The host name can be defined in the Work with TCP/IP host table entries option on the Configure TCP/IP menu (GO CFGTCP). Alternatively, you can specify *INTNETADR for the host name and specify the IP address of the system you want to access in the INTNETADR parameter.

Once FTP connects with the remote system, you'll be placed into an interactive FTP session, as shown in 3. The remote system will prompt you for your user ID and password. Once those are validated, you can begin using FTP subcommands. There are a number of standard FTP subcommands, as shown in 4.

Once FTP connects with the remote system, you'll be placed into an interactive FTP session, as shown in Figure 3. The remote system will prompt you for your user ID and password. Once those are validated, you can begin using FTP subcommands. There are a number of standard FTP subcommands, as shown in Figure 4.

Since the primary purpose of FTP is to transfer files, the two subcommands you'll probably use most are get and put. Use the get subcommand to receive a file and put to send a file. The syntax of the commands are as follows:

 get remotefile localfile put localfile remotefile 

Refer to the accompanying sidebar, "AS/400 FTP Naming Formats," for information on the naming formats for the local and remote files. When you're finished using FTP, use the quit subcommand to end the session.

Batch FTP

Another way to use FTP is from within a batch job. This method consists of three components:

1. A CL program or REXX procedure

2. An input file containing FTP subcommands

3. An output file for FTP messages

An example of this technique is shown in 5. The CL program executes two Override Database File (OVRDBF) commands. The first overrides the file INPUT to member FTPCMDS in file QTXTSRC. This causes FTP to read the source member instead of waiting for keyboard input from the user. The second command overrides file OUTPUT to member FTPLOG in file QTXTSRC. This causes FTP to write its output to the source member instead of to the screen. The FTP command is then run to access a remote system. When this command is run, the FTP subcommands in the FTPCMDS source member are executed and the output from the FTP session is written to the FTPLOG source member.

An example of this technique is shown in Figure 5. The CL program executes two Override Database File (OVRDBF) commands. The first overrides the file INPUT to member FTPCMDS in file QTXTSRC. This causes FTP to read the source member instead of waiting for keyboard input from the user. The second command overrides file OUTPUT to member FTPLOG in file QTXTSRC. This causes FTP to write its output to the source member instead of to the screen. The FTP command is then run to access a remote system. When this command is run, the FTP subcommands in the FTPCMDS source member are executed and the output from the FTP session is written to the FTPLOG source member.

A word of caution when using this technique: The user ID and password are stored unencrypted in the FTPCMDS source member. To alleviate the security risk that this could pose, be sure not to leave this source member on your system when you're through using it.

The Choice Is Yours

With FTP, IBM offers yet another way to transfer files. The strengths of FTP lie in its cross-platform capabilities, but you can also use it between like systems. FTP is a versatile tool. While it may not be the best choice in every situation, it has capabilities you won't find in any other application. When you need it, nothing else will do. As TCP/IP grows in popularity, the demand for cross-platform tools such as FTP also grows. The next time you need to transfer files between unlike systems, think about using FTP. It might just be your only choice.

Robin Klima is a senior technical editor for Midrange Computing.

REFERENCE

OS/400 TCP/IP Configuration and Reference (SC41-3420, CD ROM QBKANL00).


The AS/400 File Transfer Protocol

Related Reading

AS/400 Telnet ? September 1995

Configuring TCP/IP on the AS/400 ? August 1995

Using TCP/IP with Windows ? August 1995


The AS/400 File Transfer Protocol

AS/400 FTP Naming Formats

AS/400 FTP uses two naming formats: 0 and 1. You can switch between the two formats with the namefmt subcommand followed by 0 or 1. Namefmt 0 (the default) is a naming format only for the library file system. It uses the following formats:

 libname/filename.mbrname or libname/savfname 

Namefmt 1 is a naming format for both the hierarchical file systems and the library file system. This format allows you to specify documents, files stored on optical drives, and library system files.

To specify documents in the document library system, use this format:

 /QDLS/foldername.ext/filename.ext 

To specify files on optical drives, use the following:

 /QOPT/volname/dirname/filename.ext 

To specify save files, use the following:

 /QSYS.LIB/libname.lib/filename.savf 

To specify any other file, use the following:

 /QSYS.LIB/libname.lib/filename.file/mbrname.mbr 
The AS/400 File Transfer Protocol

Figure 1: The CHGFTPA Command


The AS/400 File Transfer Protocol

Figure 2: The FTPCommand


The AS/400 File Transfer Protocol

Figure 3: The Interactive FTPSession



The AS/400 File Transfer Protocol

Figure 4: FTP Subcommands

 Command Description ACCT Send Account Information APPEND Append a Local File Member to a Remote File ASCII Change File Type to ASCII BINARY Set Transfer Type to Image CD Change Working Directory or Library CDUP Change to Parent Directory CLOSE End an FTP Session with the Remote System DEBUG Control Display of Server Subcommands Sent to Remote System DELETE Delete a File on a Remote System DIR List Directory Entries, Libraries, or Files EBCDIC Change File Type to EBCDIC GET Copy a File from a Remote System to the Local System HELP Getting Help for FTP Subcommands LCD Change Working Library or Folder on Local System LOCSTAT Display Local Status Information LPWD Display Working Library, Folder, or Directory on Local System LS List Remote File Names LTYPE Local Type MDELETE Delete Multiple Files on a Remote System MGET Copy Multiple Files from a Remote System to the Local System MKDIR Make Directory MODE Specify Transmission Mode of Data MPUT Send Multiple Files from the Local System to a Remote System NAMEFMT Select File Naming Format NOOP Check Remote Server Response OPEN Connect to FTP Server on a Remote System PASS Send Your Password PUT Copy a File Member from the Local System to a Remote System PWD Display Current Directory, Folder, or Library QUIT Disconnect from a Remote System and End an FTP Session QUOTE Send a Subcommand to an FTP Server REINITIALIZE Reinitialize Session between Systems RENAME Rename a File on a Remote System RESET Reset the Server Reply Queue RMDIR Remove Directory SENDPORT Specify Whether a PORT Subcommand Is Sent SENDSITE Specify Whether a SITE Subcommand Is Sent SITE Send Information Used by a Remote System STATUS Retrieve Status Information from a Remote System STRUCT Specify File Structure SUNIQUE Control Overwriting of Files SYSCMD Pass an AS/400 CL Command to Your Local AS/400 System SYSTEM Remote System Description TYPE Specify File Transfer Type USER Send Your User ID to the Remote System VERBOSE Control of Text Display of Error Reply Messages 
The AS/400 File Transfer Protocol

Figure 5: FTP Batch Example

 CL Program FTPCL PGM OVRDBF FILE(INPUT) TOFILE(QTXTSRC) MBR(FTPCMDS) OVRDBF FILE(OUTPUT) TOFILE(QTXTSRC) MBR(FTPLOG) FTP RMTSYS(MC) DLTOVR FILE(INPUT OUTPUT) ENDPGM Source Member FTPCMDS klima mypaswrd get qgpl/invtrypf qgpl/invtrypf quit Source Member FTPLOG Output redirected to a file. Input read from specified override file. Connecting to host name MC at address 140.100.10.13 using port 21. 220-QTCP at MC. 220 Connection will close if idle more than 5 minutes. 215 OS/400 is the remote operating system. The TCP/IP version is "V3R1M0". Enter login ID (klima): 331 Enter password. 230 KLIMA logged on. 250 Now using naming format "0". 257 "$KLIMA" is current library. Enter an FTP subcommand. > get qgpl/invtrypf qgpl/invtrypf 200 PORT subcommand request successful. 1150 Retrieving member INVTRYPF in file INVTRYPF in library QGPL. 250 File transfer completed successfully. 330 bytes transferred in 13.110 seconds. Transfer rate 0.025 KB/sec. Enter an FTP subcommand. > quit 221 QUIT subcommand received. 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: