iSeries FTP made easy Thibault Dambrine, owner, TYLOGIX Consulting Inc. Webcast schedule Today’s event will be one hour long. Here are the expected times for each segment of the webcast: :00 – :05: Moderator introduces the speaker and discusses the details of the webcast. :05- :35: Speaker delivers a PowerPoint presentation on the webcast topic. :35- :60: Moderator and speaker engage in a Q&A on the topic. You can submit questions to the speaker at any time during the event. Just click on the “Ask a Question” button in the lower left corner of your screen. More information on www.tylogix.com Technical FAQs Here are answers to the most common technical problems users encounter during a webcast: Q: Why can’t I hear the audio part of the webcast? A: Try increasing the volume on your computer. Q: I just entered the webcast and do not see the slide that the speaker is referring to. What should I do? A: The slides are constantly be pushed to your screen. You’ll should refresh (hit F5) to view the latest slide. If your question is still not answered, please click the “Ask a Question” button in the lower left corner of your screen and submit your problem. A technical support person will respond immediately. You can also visit the Broadcast Help page for more information or to test your browser compatibility. Click here: http://help.yahoo.com/help/bcst/ More information on www.tylogix.com iSeries FTP made easy Thibault Dambrine, owner, TYLOGIX Consulting Inc. FTP client/server considerations FTP consists of two parts: the Client and the Server. The distinction between FTP client and FTP server is from the viewpoint of where the FTP commands are initiated, not from the viewpoint of where the data resides. The files being transferred may initially reside on either system. More information on www.tylogix.com FTP conversation diagram CLIENT SERVER FTP FTP TCP TCP IP IP Network Link & Hardware Network Link & Hardware More information on www.tylogix.com LOOPBACK Address With FTP, you can actually be your own Client and Server, using the well-known address called LOOPBACK. This is the equivalent of a “local controller” in the APPC world When you FTP to LOOPBACK, FTP will connect to your own system using address 127.0.0.1. The 127.0.0.1 address is consistent for ALL implementations of FTP, the LOOPBACK handle for 127.0.0.1 is consistent for MOST implementations. Practical for testing applications ASCII vs. EBCDIC EBCDIC is used nearly exclusively in IBM machines (stands for Extended Binary Coded Decimal Interchange Code) ASCII is used by the rest of the world (stands for American Standard Code for Information Interchange) FTP has to work with both Conversion from ASCII to EBCDIC and back can be done with a translation table Note: the numeric data has to be ZONED Note: ASCII and EBCDIC are “single byte” character sets More information on www.tylogix.com Three types of transfers ASCII Use if you want to purposely translate your data to ASCII - for example when the target system is a PC or a UNIX machine EBCDIC Use if you want to purposely maintain EBCDIC Coding - for example when the target system is an IBM 390 or an other AS/400 BINARY Use if you want to preserve the original content of the file and ensure NO translation takes place in the transfer of data. For example when transferring a *SAVF or a graphic image A very basic FTP application When using FTP, the user will perform some or all of the following operations: Connect to a remote host Define the transfer mode Copy files to or from the remote host More information on www.tylogix.com Opening FTP screen: FTP LOOPBACK initial screen 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 5 minutes. Enter login ID (catda7): ===>_________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ _____________________________________________________________________ F3=Exit F6=Print F17=Top F18=Bottom F9=Retrieve F21=CL command line The HELP command: What can you do with FTP? ................................................................... : FTP Client Subcommands - Help : : : : !______ ?______ ACCT___ APpend_ AScii__ Binary_ : : CD_____ CDUp___ CLose__ DEBug__ DELete_ DIr____ : : EBcdic_ Get____ Help___ LCd____ LOCSIte LOCSTat : : LPwd___ LS_____ LType__ MDelete MGet___ MKdir__ : : MOde___ MPut___ NAmefmt NOop___ Open___ PAss___ : : PUt____ PWd____ QUIt___ QUOte__ REInitialize______ : : REName_ RESet__ RMDir__ SENDPAsv__________ : : SENDPOrt__________ SENDSite__________ SIte___ STAtus_ : : STRuct_ SUnique SYSCmd_ SYSTem_ TYpe___ User___ : : Verbose : :...................................................................: Note the short-cut commands (capitalized) File naming convention when using FTP Windows/NT/UNIX: PATH\FILE.EXTENSION AS/400: LIBRARY/FILE.MEMBER If you want to target or replace a particular member with FTP, you can do so by adding the member in the command. Note: In the AS/400 system LIBRARY, FILE and MEMBER names can only be a maximum of 10 characters or fewer. Unix, Windows-based systems do not have these restrictions. File naming conventions may be a consideration when you build FTP automated applications. PUT/GET: FTP bread & butter Typical PUT and GET instructions from an AS/400 to an NT server could read as: Put library/file.member directory\file.extension Get directory\file.extension library/file.member (replace Note: The “(replace” in the Get example has no right bracket. You can do a Put or a Get using well-known address LOOPBACK Practical (manual) experimenting with FTP On your own system, connected or not, you can FTP to your own location by using the well-known address LOOPBACK First step to FTP, type FTP LOOPBACK or FTP REMOTE or FTP IP-Address FTP Put example using LOOPBACK 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 5 minutes. > catda7 331 Enter password. 230 CATDA7 logged on. OS/400 is the remote operating system. The TCP/IP version is "V4R3M0". 250 Now using naming format "0". 257 "CATDA7" is current library. > put catda7/f0911td.f0911 catda7/f0911tst 227 Entering Passive Mode (127,0,0,1,4,115). 150 Sending file to member F0911TST in file F0911TST in library CATDA7. 250 File transfer completed successfully. 2862 bytes transferred in 0.198 seconds. Transfer rate 14.437 KB/sec. ===>_______________________________________________________________________ ___________________________________________________________________________ ___________________________________________________________________________ ___________________________________________________________________________ F3=Exit F6=Print F9=Retrieve F17=Top F18=Bottom F21=CL command on line More information www.tylogix.com FTP reply codes 1yz - Positive Preliminary: The requested action is being initiated, another reply should follow. 2yz - Positive Completion: The requested action was successfully completed. A new request may be initiated. 3yz - Positive Intermediate: The command was accepted, but the requested action is being held, pending receipt of further information. 4yz - Transient Negative Completion: The command was not accepted and the requested action did not take place, but the error condition is temporary and the action may be requested again. 5yz - Permanent Negative Completion: The command was not accepted and the requested action did not take place. FTP reliability & recovery considerations FTP DOES NOT provide re-transmission services if the transmission was interrupted. This has to be done with logic in a program if you want to do it. FTP DOES NOT encrypt data when it transmits it For those and other more sophisticated types of data transfers, options such as MQ Series, Tuxedo and others are probably better options More information on www.tylogix.com FTP automation 101: What you will need A physical file to contain the command to execute (INPUT) A physical file to receive the result of your FTP request (OUTPUT) A CL program to execute the command More information on www.tylogix.com Creating an FTP input file A typical FTP input file would contain the following instructions: USER USERNAME PASSWORD ASCII or EBCDIC or BINARY PUT LIBRARY/FILE PATH\FILE More information on www.tylogix.com FTP sample input file FTPINPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 USER CATDA7 MYPASWRD EBCDIC STRUCT R PUT CATDA7/F0911TD.F0911 CATDA7/F0911NEW.NEWMBR QUIT More information on www.tylogix.com Simple FTP program: 3 commands The most basic CL program to execute an FTP command will have the following components: *************** Beginning of data ******* 0001.00 PGM 0003.00 0004.00 OVRDBF FILE(INPUT) TOFILE(FTPCMD) 0005.00 0006.00 OVRDBF FILE(OUTPUT) TOFILE(FTPLOG) 0008.00 0009.00 FTP RMTSYS(LOOPBACK) 0010.00 0011.00 DLTOVR FILE(INPUT OUTPUT) 0012.00 0013.00 ENDPGM ****************** End of data ********** More information on www.tylogix.com Automation 102 : Enhancing your automated FTP program: The three original components remain: The INPUT file The OUTPUT file The CL We will add : An RPG/C/COBOL program to customize the INPUT file with parameters An RPG/C/COBOL program to read the OUTPUT file and review/report the results of the FTP operation More information on www.tylogix.com Flexibility in automation: PGMS & PARMS PGM DCL DCL DCL DCL DCL DCL PARM (&FILE &SRCPATH &DESTPATH &USRPRF &REMOTESYS &SUCCESS) VAR(&FILE) TYPE(*CHAR) LEN(10) VAR(&SRCPATH) TYPE(*CHAR) LEN(30) VAR(&DESTPATH) TYPE(*CHAR) LEN(30) VAR(&USRPRF) TYPE(*CHAR) LEN(20) VAR(&REMOTESYS) TYPE(*CHAR) LEN(10) VAR(&SUCCESS) TYPE *CHAR) LEN(1) CALL FTPCMDPGM PARM(&FILE &SRCPATH &DESTPATH &USRPRF ) /* Program to modify the contents of FTPCMD based on parameter */ OVRDBF FILE(INPUT) OVRDBF FILE(OUTPUT) TOFILE(FTPCMD) TOFILE(FTPLOG) FTP &REMOTESYS /* Execute the FTP Command */ CALL FTPMONITOR PARM(&SUCCESS) /* Program to read the FTPLOG file and verify that the FTP result is successful */ DLTOVR FILE(INPUT OUTPUT) More information on www.tylogix.com ENDPGM Real-life experience: Successful transfer Note the positioning of the USER/PASSWORD Combination in the INPUT file Note the File and Member Combinations in the INPUT file Note the Reply Codes and where they are in relation to the commands in the OUTPUT file More information on www.tylogix.com FTP input for a successful transfer FTPINPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 USER CATDA7 MYPASWRD EBCDIC STRUCT R PUT CATDA7/F0911TD.F0911 CATDA7/F0911NEW.NEWMBR QUIT More information on www.tylogix.com FTP output for a successful transfer (1 of 2) FTPOUTPUT 000001 Output redirected to a file. 000002 Input read from specified override file. 000003 Connecting to host LOOPBACK at address 127.0.0.1 using port 21. 000004 220-QTCP at LOOPBACK. 000005 220 Connection will close if idle more than 5 minutes. 000006 Enter login ID (catda7): 000007 331 Enter password. 000008 OS/400 is the remote operating system. The TCP/IP version is "V4R3M0". 000009 250 Now using naming format "0". 000010 Enter an FTP subcommand. 000011 > USER CATDA7 ******** 000012 331 Enter password. 000013 230 CATDA7 logged on. 000014 OS/400 is the remote operating system. The TCP/IP version is "V4R3M0". 000015 250 Now using naming format "0". 000016 257 "CATDA7" is current library. 000017 Enter an FTP subcommand. 000018 > 000019 Enter an FTP subcommand. 000020 > EBCDIC 000021 200 Representation type is EBCDIC nonprint. 000022 Enter an FTP subcommand. 000023 > More information on www.tylogix.com FTP output for a successful transfer (2 of 2) FTPOUTPUT 000024 Enter an FTP subcommand. 000025 > STRUCT R 000026 250 Data structure is record. 000027 Using structure R to transfer files. 000028 Enter an FTP subcommand. 000029 > 000030 Enter an FTP subcommand. 000031 > PUT CATDA7/F0911TD.F0911 CATDA7/F0911NEW.NEWMBR 000032 227 Entering Passive Mode (127,0,0,1,5,9). 000033 150 Sending file to member NEWMBR in file F0911NEW in library CATDA7. 000034 250 File transfer completed successfully. 000035 5193 bytes transferred in 0.326 seconds. Transfer rate 15.921 KB/sec. 000036 Enter an FTP subcommand. 000037 > 000038 Enter an FTP subcommand. 000039 > QUIT 000040 221 QUIT subcommand received. More information on www.tylogix.com Member missing or wrong member unsuccessful transfer Note the File and Member Combinations in the INPUT file Note the Reply Codes in the OUTPUT file More information on www.tylogix.com FTP input for an unsuccessful transfer FTPINPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 USER CATDA7 MYPASWRD EBCDIC STRUCT R PUT CATDA7/F0911TD CATDA7/F0911NEW QUIT More information on www.tylogix.com FTP output for an unsuccessful transfer (1 of 2) FTPOUTPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 000020 000021 000022 000023 Output redirected to a file. Input read from specified override file. 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 5 minutes. Enter login ID (catda7): 331 Enter password. OS/400 is the remote operating system. The TCP/IP version is "V4R3M0". 250 Now using naming format "0". Enter an FTP subcommand. > USER CATDA7 ******** 331 Enter password. 230 CATDA7 logged on. OS/400 is the remote operating system. The TCP/IP version is "V4R3M0". 250 Now using naming format "0". 257 "CATDA7" is current library. Enter an FTP subcommand. > Enter an FTP subcommand. > EBCDIC 200 Representation type is EBCDIC nonprint. Enter an FTP subcommand. > More information on www.tylogix.com FTP output for an unsuccessful transfer (2 of 2) FTPOUTPUT 000024 000025 000026 000027 000028 000029 000030 000031 000032 000033 000034 000035 000036 000037 Enter an FTP subcommand. > STRUCT R 250 Data structure is record. Using structure R to transfer files. Enter an FTP subcommand. > Enter an FTP subcommand. > PUT CATDA7/F0911TD CATDA7/F0911NEW Member F0911TD in file F0911TD in library CATDA7 not found. Enter an FTP subcommand. > Enter an FTP subcommand. > QUIT 221 QUIT subcommand received More information on www.tylogix.com Unrecognized user profile unsuccessful transfer Note the positioning of the USER/PASSWORD Combination in the INPUT file Note the Reply Codes in the OUTPUT file More information on www.tylogix.com FTP input for a successful transfer (Reminder) FTPINPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 USER CATDA7 MYPASWRD EBCDIC STRUCT R PUT CATDA7/F0911TD.F0911 CATDA7/F0911NEW.NEWMBR QUIT More information on www.tylogix.com FTP input with user profile unrecognized FTPINPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 USER CATDA7 MYPASWRD EBCDIC STRUCT R PUT CATDA7/F0911TD.F0911 CATDA7/F0911NEW.NEWMBR QUIT More information on www.tylogix.com FTP output for unrecognized user (1 of 2) FTPOUTPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 000013 000014 000015 000016 000017 000018 000019 Output redirected to a file. Input read from specified override file. 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 5 minutes. Enter login ID (catda7): Number of arguments for a prompted login to the server not correct. Enter an FTP subcommand. > Enter an FTP subcommand. > EBCDIC 200 Representation type is EBCDIC nonprint. Enter an FTP subcommand. > Enter an FTP subcommand. > STRUCT 250 Data structure is record. Using structure R to transfer files. Enter an FTP subcommand. More information on www.tylogix.com FTP output for unrecognized user (2 of 2) FTPOUTPUT 000020 000021 000022 000023 000024 000025 000026 000027 000028 > Enter an FTP subcommand. > PUT CATDA7/F0911TD.F0911 CATDA7/F0911NEW.NEWMBR You must first issue the USER subcommand. Enter an FTP subcommand. > Enter an FTP subcommand. > QUIT 221 QUIT subcommand received. More information on www.tylogix.com The Quote Command in the AS/400 The Quote Command allows you to run commands on the remote system you are FTP-ing to. To get the syntax of the QUOTE command, type in: HELP QUOTE To get the list of the commands supported via QUOTE on the remote system, type in: QUOTE HELP Most useful QUOTE command: RCMD (Remote Command) To get help on any of the remote system’s command (i.e. for RCMD), type QUOTE RCMD HELP Note: The AS/400 has a 1,000 character limit on a Quote command Typical use for the QUOTE Command after a PUT FTPINPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 USER CATDA7 MYPASWRD EBCDIC STRUCT R PUT LOCLIB/F0911TD.F0911 REMLIB/F0911NEW.NEWMBR QUOTE RCMD CALL PROCESSPGM QUIT More information on www.tylogix.com Typical use for the QUOTE Command before a GET FTPINPUT 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 000011 000012 USER CATDA7 MYPASWRD QUOTE RCMD CALL GATHERPGM EBCDIC STRUCT R GET REMLIB/F0911TD.F0911 LOCLIB/F0911NEW.NEWMBR QUIT More information on www.tylogix.com Beef up your FTP security with EXIT programs of 3) Your AS/400 Server FTP request from the outside world UserDefined Exit Program (will receive parameters and act as a gate, allowing or not the FTP request to proceed) User-defined FTP security parameters Access to the file server file system More information on www.tylogix.com Beef up your FTP security with EXIT programs of 3) Typically, an FTP Exit program will receive the following parameters and will decide with a return value if the operation is allowed. 1) Application ID (FTPClient for example) 2) Operation ID (Sending a file for example) 3) User profile 4) Remote IP address 5) Length of remote IP address 6) Operation 7) Length of operation 8) Allow Operation (this value when returned will determine if the operation will be allowed) Beef up your FTP security with EXIT programs of 3) Where are EXIT programs accessed on the AS/400? WRKREGINF displays a list of the various system exit points What is the ID of the FTP Exit point? The Exit point for FTP is QIBMQTMF_SVR_LOGON. This is where you specify a user-built program that is called every time a user tries to log on to your AS/400 via FTP More information on www.tylogix.com Questions? Submit your questions now by clicking on on the “Ask A Question” button in the left corner of your presentation screen. Thibault will answer your questions off-line. The questions and answers will then be posted on Search400.com. We will e-mail you when your question has been answered. More information on www.tylogix.com