Booth Martin; Contract 
Programming, Inc.
28 Delmont Avenue
Barre, Vermont 05641
802-476-7942
boothm@ibm.net



Below are several programs relating to providing an easily setup user FTP utility for IBM's AS/400. Features of this series include:
a) scripts are saved from session to session so a similar FTP transaction is easily repeatable by occasional users.
b) each script is uniquely keyed, so each FTP operation's specific script is saved for later use, including the site's address and log-in name.
c) each script's key is a two-part key providing individual and/or departmental uniqueness.


The User's Screen, with the default script, ready for a password.
The User's Screen with a script, ready for a password. This script was saved automatically from the last time that "CALL FTP10CL (spy booth)" was run. The script will:
change the target machine's directory to "public_html"
transfer the member "ftp10fm" in file "qftp" in the Current Library
to a new file named "ftp10fm.txt" on the server "secret.spy.net"
and then do the same for "plibr/QFTP/FTP10"
and then quit.


The FTP log screen from another session that was run the User's Screen's script.
An FTP log generated from a typical FTP script. The FTP log can be directed to the screen as shown here, or to a log file and never be seen by the user.

The DSPF Screen format for this series
The file layouts for this series
The RPG for this series
Top of page

The CL program for this series of FTP programs


The CL code:

             PGM        PARM(&PROFILE &USEROR)
             DCL        VAR(&PROFILE) TYPE(*CHAR) LEN(10)
             DCL        VAR(&USEROR) TYPE(*CHAR) LEN(10)
             DCL        VAR(&M1HOST) TYPE(*CHAR) LEN(20)
             DCL        VAR(&EXIT) TYPE(*CHAR) LEN(3)
             CHGVAR     VAR(&EXIT) VALUE('NO ')

  /* The PARM &PROFILE is provided as a key field for getting the correct   +
     default information for the FTP script file for the application.    +
     It can be any unique name.  It will write a new record with the     +
     key being &PROFILE + User's name.                                     */

  /* The PARM &USEROR allows the CL to specify a common USER for      +
     the FTP application, and not be different for each independant      +
     user of the application.  It is designed to allow a departmental    +
     PROFILE for a departmental application.                            */

  /* The file FTP10W is a regular data file designed to hold the working +
     Script file records for the RPG display screen program.             +
     The file FTP10W will be processed in QTEMP as the Password is saved +
     in it, in the clear.                                                +
     The script file must be a Source Physical File however, so once     +
     the script is set, it must be copied over with FMTOPT(*CVTSRC).     +
     The copied-over source library/file/member is QTEMP/QFTP/FTPCMDS    */

             CHKOBJ     OBJ(QTEMP/FTP10W) OBJTYPE(*FILE) /* if not +
                          there, make it there. */
             MONMSG     MSGID(CPF9801) EXEC(DO)
             CRTDUPOBJ  OBJ(FTP10W) FROMLIB(ISY2) OBJTYPE(*FILE) +
                          TOLIB(QTEMP)
             ENDDO
             CLRPFM     FILE(QTEMP/FTP10W)
             OVRDBF     FILE(FTP10W) TOFILE(QTEMP/FTP10W)
             CHGVAR     VAR(&EXIT) VALUE('NO ')
             CALL       PGM(FTP10) PARM(&PROFILE &M1HOST &EXIT &USEROR)
             IF         COND(&EXIT *EQ 'YES') THEN(RETURN)

             CHKOBJ     OBJ(QTEMP/QFTP) OBJTYPE(*FILE) /* if not +
                          there, copy it there. */
             MONMSG     MSGID(CPF9801) EXEC(DO)
             CRTDUPOBJ  OBJ(QFTP) FROMLIB(ISY2) OBJTYPE(*FILE) +
                          TOLIB(QTEMP)
             ENDDO

             CPYF       FROMFILE(QTEMP/FTP10W) TOFILE(QTEMP/QFTP) +
                          TOMBR(FTPCMDS) MBROPT(*REPLACE) +
                          CRTFILE(*NO) FMTOPT(*CVTSRC) /* Create +
                          FTP script file as a Source Physical File */
             OVRDBF     FILE(INPUT) TOFILE(QTEMP/QFTP) MBR(FTPCMDS)

  /*         OVRDBF     FILE(OUTPUT) TOFILE(ISY2/QFTP) MBR(FTPLOG)   +
             By commenting this command the FTP process prints the   +
             log file to the screen.  Uncommenting the command will  +
             print and save the log in ISY2/QFTP/FTPLOG              */

             IF         COND(&EXIT *NE 'YES') THEN(FTP +
                          RMTSYS(&M1HOST) CCSID(437)) /* code page +
                          437 is the text default: */

             ENDPGM


The DSPF Screen format for this series
The file layouts for this series
The CL for this series
Top of page


RPG for default Script Display
     H            Y
     /****************************************************************/            
     /*  SOURCE       -  FTP10                                       */
     /*  PROGRAMMER   -  BOOTH MARTIN                                */
     /*  DATE         -   3/98                                       */
     /*  COMMENTS     -  A PROGRAM TO DISPLAY FTP DEFAULT VALUES,    */
     /*                  ALLOW KEYING IN NEW VALUES, AND             */
     /*                  WRITING BACK THE VALUES, PLUS               */
     /*                  WRITING OUT AN FTP SCRIPT FILE.             */
     /****************************************************************/
     FFTP10FM CF  E                    WORKSTN
     FFTP10P  UF  E           K        DISK                      A
     FFTP10W  O   E                    DISK
      * A Named Constant field - (in case user name is blank.)
     I              'Anonymous'           C         NC01
     I           SDS
     I                                      254 263 USER
      * *============================================================= *
      * INDICATOR USAGE:
      *  31 = Name in default record, position cursor at Password field.
      *  32 = NO PASSWORD, RE-DO
      *  33 = UNPROTECTS FIELDS; default is "protect" use F23 UNPROTECT
      *  54 = CHAIN INDICATOR
      *  KL = Return to calling program, script not written.
      *  "PROF" is used to pass in a profile for this process. It is
      *  PROF + USER is the key to look up a  default Script Record.
      *  PB1 is the pushbutton field on the screen.
      * *=============================================================*
     C           *ENTRY    PLIST
     C                     PARM           PROF             WHAT PROGRAM?
     C                     PARM           M1HOST           HOST SITE
     C                     PARM           EXIT
     C                     PARM           USEROR           USER OVERRIDE
      *  ..  ..
     C                     Z-ADD*ZEROS    PB1
     C                     EXFMTFTP10A
     C                     SELEC
     C*
      *  ..  KL? Exit/cancel; don't do process:
     C           *INKL     WHEQ *ON
     C           PB1       OREQ 1
     C                     MOVE 'YES'     EXIT    3
     C                     MOVE *ON       *INLR
     C*
      *  ..  KX?
     C           *INKX     WHEQ *ON
     C           PB1       OREQ 2
     C           *IN33     IFEQ *ON
     C                     MOVE *OFF      *IN33
     C                     ELSE
     C                     MOVE *ON       *IN33
     C                     END
     C*
      *  ..  Password blank?
     C           M1PASS    WHEQ *BLANKS
     C                     MOVE *ON       *IN32
     C*
     C*  ..  Otherwise, process the screen:
     C                     OTHER
     C           KEY1      CHAINFTP10R1              54
     C                     MOVE M1HOST    M0HOST
     C                     MOVE M1NAME    M0NAME
     C*** DON'T SAVE:      MOVE M1PASS    M0PASS
     C                     MOVE M1LN2     M0LN2
     C                     MOVE M1LN3     M0LN3
     C                     MOVE M1LN4     M0LN4
     C                     MOVE M1LN5     M0LN5
     C                     MOVE M1LN6     M0LN6
     C                     MOVE M1LN7     M0LN7
     C                     MOVE *DATE     M0DATO
     C                     TIME           M0TIMO
     C           *IN54     IFEQ *ON
     C                     MOVE PROF      M0PROF
     C                     MOVE USER      M0USRO
     C                     WRITEFTP10R1
     C                     ELSE                            *IN54 IFEQ *ON
     C                     UPDATFTP10R1
     C                     END                             X-*IN54 IFEQ *ON
     C* MAKE THE RECORDS FOR THE FTP SCRIPT FILE:
     C* LINE 1:
     C                     MOVE *BLANKS   M0LINE
     C           M1NAME    CAT  M1PASS:1  M0LINE
     C           M0LINE    IFGT *BLANKS
     C                     WRITEFTP10R2
     C                     END
     C* LINE 2:
     C                     MOVE *BLANKS   M0LINE
     C                     MOVELM1LN2     M0LINE
     C           M0LINE    IFGT *BLANKS
     C                     WRITEFTP10R2
     C                     END
     C* LINE 3:
     C                     MOVE *BLANKS   M0LINE
     C                     MOVELM1LN3     M0LINE
     C           M0LINE    IFGT *BLANKS
     C                     WRITEFTP10R2
     C                     END
     C* LINE 4:
     C                     MOVE *BLANKS   M0LINE
     C                     MOVELM1LN4     M0LINE
     C           M0LINE    IFGT *BLANKS
     C                     WRITEFTP10R2
     C                     END
     C* LINE 5:
     C                     MOVE *BLANKS   M0LINE
     C                     MOVELM1LN5     M0LINE
     C           M0LINE    IFGT *BLANKS
     C                     WRITEFTP10R2
     C                     END
     C* LINE 6:
     C                     MOVE *BLANKS   M0LINE
     C           M0LINE    IFGT *BLANKS
     C                     MOVELM1LN6     M0LINE
     C                     WRITEFTP10R2
     C                     END
     C* LINE 7:
     C                     MOVE *BLANKS   M0LINE
     C                     MOVELM1LN7     M0LINE
     C           M0LINE    IFGT *BLANKS
     C                     WRITEFTP10R2
     C                     END
      * Present job finished normally:
     C                     MOVE *ON       *INLR
     C*
     C                     ENDSL
     C*
      * *=============================================================*
      * *==           SUB ROUTINES                                  ==*
      * *=============================================================*
     C           *INZSR    BEGSR
     C           *LIKE     DEFN M0PROF    PROF
     C           *LIKE     DEFN USER      USEROR
     C           KEY1      KLIST
     C                     KFLD           PROF
     C                     KFLD           USER
     C           USEROR    IFGT *BLANKS
     C                     MOVE USEROR    USER
     C                     END
     C           KEY1      CHAINFTP10R1              54
     C           *IN54     IFEQ *OFF
      * USUALLY THE PARM-IN WILL BE EMPTY, BUT IF NOT, USE IT.
     C           M1HOST    IFEQ *BLANKS
     C                     MOVE M0HOST    M1HOST
     C                     END
     C                     MOVE *BLANKS   M1PASS
     C* If name is blank, substitute "anonymous"
     C* otherwise, move in the name and set the cursor at Password field.
     C           M0NAME    IFEQ *BLANKS
     C                     MOVELNC01      M1NAME
     C                     ELSE
     C                     MOVE M0NAME    M1NAME
     C                     MOVE *ON       *IN31
     C                     END
     C                     MOVE *BLANKS   M1PASS
     C                     MOVE M0LN2     M1LN2
     C                     MOVE M0LN3     M1LN3
     C                     MOVE M0LN4     M1LN4
     C                     MOVE M0LN5     M1LN5
     C                     MOVE M0LN6     M1LN6
     C                     MOVE M0LN7     M1LN7
     C                     END                             *IN54 IFEQ *OFF
     C                     ENDSR

The DSPF Screen format for this series
The RPG for this series
The CL for this series
Top of page


File FTP10P
(the saved Script Lines, for the default FTP screen set up)

     A*  COMMENTS     -  FILE FOR DEFAULTS FOR THE FTP FUNCTION      */
     A* ------------------------------------------------------------ */
     A* ------------------------------------------------------------ */
     A*                                                              */
     A***************************************************************/
     A          R FTP10R1
     A*
     A            M0HOST        20          TEXT('HOST SITES NAME')
     A            M0NAME        20          TEXT('USERS NAME AT HOST')
     A            M0PASS        20          TEXT('PASSWORD AT HOST')
     A            M0LN2         45          TEXT('LINE 2')
     A            M0LN3         45          TEXT('LINE 3')
     A            M0LN4         45          TEXT('LINE 4')
     A            M0LN5         45          TEXT('LINE 5')
     A            M0LN6         45          TEXT('LINE 6')
     A            M0LN7         45          TEXT('LINE 7')
     A**********************
     A* AUDIT TRAIL FIELDS *
     A**********************
     A            M0PROG        10          TEXT('PROGRAM')
     A* LAST OPENED BY:    *
     A            M0USRO        10          TEXT('USER')
     A            M0DATO         8S 0       TEXT('DATE')
     A            M0TIMO         6S 0       TEXT('TIME')
     A          K M0PROG
     A          K M0USRO



File FTP10W
(The new Script File to do the actual File Transfer)
(normally exists but only QTEMP has any data)
(This file will be copied with *CVTSRC)


     A*  COMMENTS     -  FILE FOR SCRIPT LINES                       */
     A* ------------------------------------------------------------ */
     A* ------------------------------------------------------------ */
     A*                                                              */
     A***************************************************************/
     A          R FTP10R2
     A*
     A            M0LINE        92          TEXT('SCRIPT')

The file layouts for this series
The RPG for this series
The CL for this series
Top of page


The DDS code:
     A*%%TS  SD  19980513  092605  BOOTH       REL-V4R2M0  5769-PW1
     A****************************************************************/              
     A*  SOURCE       -  FTP10FM                                     */
     A*  PROGRAMMER   -  BOOTH MARTIN                                */
     A*  DATE         -   3/98                                       */
     A*  COMMENTS     -  DISPLAY FTP DEFAULTS, COLLECT VALUES FOR    */
     A*  BUILDING AN FTP SCRIPT.                                     */
     A*                                                              */
     A*  NOTE: IF THIS SCREEN DOESN'T DISPLAY CORRECTLY THE SECOND   */
     A*  TIME IT IS DISPLAYED, COMPILE IT WITH 14, AND AN F4 PROMPT. */
     A*  CHOOSE F10, ADDITIONAL PARAMETERS AND RESTORE DISPLAY *YES  */
     A*  (This display looks best if used on an enhanced display)    */
     A*                                                              */
     A****************************************************************/
     A*%%EC
     A                                      DSPSIZ(24 80 *DS3)
     A                                      CHGINPDFT(HI UL LC)
     A                                      MSGLOC(12)
     A                                      PRINT
     A                                      CF12(12 'CANCEL')
     A                                      CF23(23 'UNPROTECT')
     A          R FTP10A
     A*%%TS  SD  19980513  092605  BOOTH       REL-V4R2M0  5769-PW1
     A                                      WINDOW(6 15 12 60)
     A                                      OVERLAY
     A                                      WDWTITLE((*TEXT ' FTP Information '-
     A                                      ))
     A            M1HOST    R        B  1 16REFFLD(FTP10R1/M0HOST *LIBL/FTP10P)
     A N33                                  DSPATR(PR)
     A            M1NAME    R        B  2 16REFFLD(FTP10R1/M0NAME *LIBL/FTP10P)
     A            M1PASS    R        B  3 16REFFLD(FTP10R1/M0PASS *LIBL/FTP10P)
     A  31                                  DSPATR(PC)
     A                                      DSPATR(ND)
     A  32                                  ERRMSGID(FTP0010 QGPL/ERRMSGP 32)
     A                                  1  1'CONNECTING TO:'
     A                                  2  1'USER NAME  . :'
     A                                  3  1'USER PASSWORD:'
     A                                  4  1'SCRIPT FILE  :'
     A                                  5  1'              '
     A                                  1 37'                        '
     A                                  2 37'                        '
     A                                  3 37'                        '
     A            M1LN3     R        B  5 16REFFLD(FTP10R1/M0LN3 *LIBL/FTP10P)
     A N33                                  DSPATR(PR)
     A            M1LN2     R        B  4 16REFFLD(FTP10R1/M0LN2 *LIBL/FTP10P)
     A N33                                  DSPATR(PR)
     A            M1LN4     R        B  6 16REFFLD(FTP10R1/M0LN4 *LIBL/FTP10P)
     A N33                                  DSPATR(PR)
     A            M1LN5     R        B  7 16REFFLD(FTP10R1/M0LN5 *LIBL/FTP10P)
     A N33                                  DSPATR(PR)
     A            M1LN6     R        B  8 16REFFLD(FTP10R1/M0LN6 *LIBL/FTP10P)
     A N33                                  DSPATR(PR)
     A            M1LN7     R        B  9 16REFFLD(FTP10R1/M0LN7 *LIBL/FTP10P)
     A N33                                  DSPATR(PR)
     A            PB1            2Y 0B 11  1PSHBTNFLD
     A                                      CHCAVAIL((*COLOR BLU))
     A                                      PSHBTNCHC(1 'F12=Cancel' CF12)
     A N33                                  PSHBTNCHC(2 'F23=Unprotect' CF23)
     A  33                                  PSHBTNCHC(3 'F23=  Protect' CF23)
     A          R DUMMY
     A                                      TEXT('PREVENTS PREVIOUS SCREEN FROM-
     A                                       BEING CLEARED')
     A                                      ASSUME
     A                                  5  9' '

For comments or questions, leave e-mail
The DSPF Screen format for this series
The file layouts for this series
The RPG for this series
The CL for this series
Top of page
Home page