Attached are four source members. Either FTP them to your AS/400 or reenter 
them. The BLDFTP1R and CHKFTP1R are RPGLE, The FTPBATCH is a CMD and teh 
STRFTTP1C
is a CLP. You can use this command in a CL Program. If you need to talk please 
feel free to call me.

"Gokhan Yildirim (Garanti Teknoloji)" wrote:

> Hello everyone,
> I would like to ask about STRTCPFTP command... How can i write a script for 
>doing commands within  a CL program?  I don't want users to change something...
>
> Gökhan YILDIRIM
> GARANTI TECHNOLOGY
> Evren Mah. Kocman Cad. No:22
> 34550 - Günesli / Bagcilar
> ISTANBUL / TURKEY
> Tel : 90 + (212) 657 04 04 / 1336 Dahili
> Faks: 90 + (212) 657 04 73
> mailto: GokhanY@Garanti.Com.TR
> +---
> | This is the Midrange System Mailing List!
> | To submit a new message, send your mail to MIDRANGE-L@midrange.com.
> | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com.
> | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator: david@midrange.com
> +---

--
Bruce Collins
MIS Manager
Twitchell Corporation
4031 Ross Clark Circle NW
Dothan, AL 36303
bacollins@twitchelltextilene.com
(334) 792-0002 x 1266
(334) 673-4121 Fax

/********************************************************************/
/*                                                                  */
/*                      PROGRAM FUNCTION                            */
/*                                                                  */
/* This is the CPP for command FTPBATCH.                            */
/*                                                                  */
/* It performs a batch FTP transfer of one file with a TCP/IP       */
/* network connected FTP server.                                    */
/*                                                                  */
/* Program parameters:                                              */
/*                                                                  */
/*         &TGTSYS    (in )   -   Target system                     */
/*         &LCLFIL    (in )   -   Local file name                   */
/*         &RMTFIL    (in )   -   Remote file name                  */
/*         &FUNCTION  (in )   -   Function to be executed           */
/*                        values: 'P' = Put                         */
/*                                'G' = Get                         */
/*         &USR       (in )   -   User ID in remote system          */
/*         &PWD       (in )   -   Password in remote system         */
/*         &CMD1      (in )   -   Optional FTP subcommand           */
/*                                (Executed before transfer)        */
/*         &CMD2      (in )   -   Optional FTP subcommand           */
/*                                (Executed before transfer)        */
/*         &CMD3      (in )   -   Optional FTP subcommand           */
/*                                (Executed before transfer)        */
/*         &SUCCES    (out)   -   Success indicator                 */
/*                        values: '0' = Transfer failed             */
/*                                '1' = Transfer successful         */
/*                                                                  */
/* All work files are created into library QTEMP.                   */
/*                                                                  */
/* Programs called:                                                 */
/*                                                                  */
/*         BLDFTP1R (ILE RPG) -   Creates the FTP script            */
/*                                for transfer                      */
/*         CHKFTP1R (ILE RPG) -   Checks the success of transfer    */
/*                                by reading the FTP transfer log   */
/*                                                                  */
/********************************************************************/
             PGM        PARM(&TGTSYS   +
                             &LCLFIL   +
                             &RMTFIL   +
                             &FUNCTION +
                             &USR      +
                             &PWD      +
                             &CMD1     +
                             &CMD2     +
                             &CMD3     +
                             &SUCCES   )

/********************************************************************/
/* Parameters                                                       */
/********************************************************************/
             DCL        VAR(&TGTSYS  ) TYPE(*CHAR) LEN(50)
             DCL        VAR(&LCLFIL  ) TYPE(*CHAR) LEN(50)
             DCL        VAR(&RMTFIL  ) TYPE(*CHAR) LEN(50)
             DCL        VAR(&FUNCTION) TYPE(*CHAR) LEN(1 )
             DCL        VAR(&USR     ) TYPE(*CHAR) LEN(10)
             DCL        VAR(&PWD     ) TYPE(*CHAR) LEN(10)
             DCL        VAR(&CMD1    ) TYPE(*CHAR) LEN(20)
             DCL        VAR(&CMD2    ) TYPE(*CHAR) LEN(20)
             DCL        VAR(&CMD3    ) TYPE(*CHAR) LEN(20)
             DCL        VAR(&SUCCES  ) TYPE(*CHAR) LEN(1)

/********************************************************************/
/* Local variables                                                  */
/********************************************************************/
             DCL        VAR(&OKCODE  ) TYPE(*CHAR) LEN(3)
             DCL        VAR(&ON      ) TYPE(*CHAR) LEN(1) VALUE('1')
             DCL        VAR(&OFF     ) TYPE(*CHAR) LEN(1) VALUE('0')

/********************************************************************/
/* Delete/Create the FTP script file                                */
/********************************************************************/
             DLTF       FILE(QTEMP/FTPCMD)
             MONMSG     MSGID(CPF0000)
             CRTSRCPF   FILE(QTEMP/FTPCMD) MBR(FTP)

/********************************************************************/
/* Build the FTP script                                             */
/********************************************************************/
             OVRDBF     FILE(FTPCMD) TOFILE(QTEMP/FTPCMD) MBR(FTP)
             CALL       PGM(BLDFTP1R) PARM(&USR &PWD &FUNCTION +
                                           &LCLFIL &RMTFIL &CMD1 &CMD2 &CMD3)

/********************************************************************/
/* Delete/Create the FTP transfer log file                          */
/********************************************************************/
             DLTF       FILE(QTEMP/FTPLOG)
             MONMSG     MSGID(CPF0000)
             CRTPF      FILE(QTEMP/FTPLOG) RCDLEN(132) MBR(FTPLOG)

/********************************************************************/
/* Execute FTP transfer                                             */
/********************************************************************/
             OVRDBF     FILE(INPUT ) TOFILE(QTEMP/FTPCMD) MBR(FTP)
             OVRDBF     FILE(OUTPUT) TOFILE(QTEMP/FTPLOG) MBR(FTPLOG)
             STRTCPFTP  RMTSYS(&TGTSYS)
             DLTOVR     FILE(*ALL)

/********************************************************************/
/* Check FTP transfer log file to find out if the transfer was      */
/* successful                                                       */
/********************************************************************/
             CALL       PGM(CHKFTP1R) PARM(&OKCODE)
             IF         COND(&OKCODE *EQ 'YES') THEN(CHGVAR +
                          VAR(&SUCCES) VALUE(&ON))
             ELSE       CMD(CHGVAR VAR(&SUCCES) VALUE(&OFF))

             ENDPGM
     F/TITLE CHECK FTP LOG
      ********************************************************************
      *                                                                  *
      * This program reads through the FTP transfer log file and         *
      * tries to find out if the transfer was successful.                *
      *                                                                  *
      ********************************************************************
      *                                                                  *
      ********************************************************************
     F/SPACE 3
      ********************************************************************
      *                                                                  *
      *                       INDICATOR USAGE                            *
      *                                                                  *
      *   IND.  DESCRIPTION                                              *
      *                                                                  *
      *    99 - FTPLOG EOF                                               *
      *    LR - CLOSE FILES ON EXIT                                      *
      *                                                                  *
      ********************************************************************
     F/SPACE 3
     F/EJECT
      ********************************************************************
      *FILES USED BY THIS PROGRAM
      ********************************************************************
     FFTPLOG    IF   F  132        DISK
     F/EJECT
      ********************************************************************
      * DATA STRUCTURES USED BY THIS PROGRAM                             *
      ********************************************************************
      *
      * Define constants
      *
     D FileXfer        C                   CONST('File transfer')
      *
      * Define input record format
      *
     D LogRec          DS           132
     D  ReplyCode              1      3
     D  ExtraInfo              5     17
     C/EJECT
      ********************************************************************
      * VARIABLE DEFINITIONS AND LISTS USED BY THIS PROGRAM              *
      ********************************************************************
     C/SPACE 2
     C     *ENTRY        PLIST
      * Return parameters:
     C                   PARM                    OK                3
      *                                                    possible values:   NO
      *                                                                       YE
     C/EJECT
      ********************************************************************
      * The Main Program                                                 *
      ********************************************************************
      *
     C                   MOVE      'NOT'         OK
      *
     C     *IN99         DOWEQ     *OFF
     C                   READ      FTPLOG        LogRec                   99
     C     *IN99         IFEQ      *OFF
      *
     C                   SELECT
      * Remote system was something else than an AS/400 or any other that uses 2
     C     ReplyCode     WHENEQ    '226'
     C                   MOVE      'YES'         OK
     C                   LEAVE
      *
      * Remote system was an AS/400 or any other that uses 250 as a response
     C     ReplyCode     WHENEQ    '250'
     C     ExtraInfo     ANDEQ     FileXfer
     C                   MOVE      'YES'         OK
     C                   LEAVE
      *
     C                   ENDSL
     C                   ENDIF
     C                   ENDDO
      *
     C                   EVAL      *INLR = *ON
     C                   RETURN
     C/EJECT
      ********************************************************************
      *                                                                  *
      * ...and here be the dragons.                                      *
      *                                                                  *
      ********************************************************************
 FTPBATCH:   CMD        PROMPT('START A FTP BATCH TRANSFER')
             PARM       KWD(RMTSYS) TYPE(*CHAR) LEN(50) MIN(1) +
                          PROMPT('Remote system for FTP transfer')
             PARM       KWD(LCLFIL) TYPE(*CHAR) LEN(50) MIN(1) +
                          PROMPT('Local file''s name')
             PARM       KWD(RMTFIL) TYPE(*CHAR) LEN(50) MIN(1) +
                          PROMPT('Remote file''s name')
             PARM       KWD(FUNCTION) TYPE(*CHAR) LEN(1) RSTD(*YES) +
                          VALUES(P G) SPCVAL((p P) (g G)) MIN(1) +
                          PROMPT('Function (Put/Get)')
             PARM       KWD(USR) TYPE(*CHAR) LEN(10) MIN(1) +
                          PROMPT('User profile in remote system')
             PARM       KWD(PWD) TYPE(*CHAR) LEN(10) MIN(1) +
                          PROMPT('Password to remote system')
             PARM       KWD(CMD1) TYPE(*CHAR) LEN(20) DFT( ) +
                          PROMPT('User defined FTP command 1')
             PARM       KWD(CMD2) TYPE(*CHAR) LEN(20) DFT( ) +
                          PROMPT('User defined FTP command 2')
             PARM       KWD(CMD3) TYPE(*CHAR) LEN(20) DFT( ) +
                          PROMPT('User defined FTP command 3')
             PARM       KWD(SUCCES) TYPE(*CHAR) LEN(1) RTNVAL(*YES) +
                          PROMPT('1=Transfer successful / 0=Not')
     F/TITLE CREATE FTP SCRIPT
      ********************************************************************
      *                                                                  *
      * This program creates the FTP script for FTPBATCH command.        *
      *                                                                  *
      ********************************************************************
      *                                                                  *
      ********************************************************************
     F/SPACE 3
      ********************************************************************
      *                                                                  *
      *                       INDICATOR USAGE                            *
      *                                                                  *
      *   IND.  DESCRIPTION                                              *
      *                                                                  *
      *    LR - CLOSE FILES ON EXIT                                      *
      *                                                                  *
      ********************************************************************
     F/EJECT
      ********************************************************************
      *FILES USED BY THIS PROGRAM
      ********************************************************************
     FFTPCMD    O    F   92        DISK
     D/EJECT
      ********************************************************************
      * DATA STRUCTURES USED BY THIS PROGRAM
      ********************************************************************
     D/SPACE 2
      *
      * Source file record format
      *
     D CmdRec          DS
     D  SRCSEQ                 1      6  2
     D  SRCDAT                 7     12  0
     D  SRCDTA                13     92
     C/EJECT
      ********************************************************************
      * VARIABLE DEFINITIONS AND LISTS USED BY THIS PROGRAM              *
      ********************************************************************
     C/SPACE 2
      *
      * Define parameter list
      *
     C     *ENTRY        PLIST
     C                   PARM                    RMTUSR           10
     C                   PARM                    RMTPWD           10
     C                   PARM                    FUNCTION          1
      *                                                    possible values:   P
      *                                                                       G
     C                   PARM                    LCLFIL           50
      *
     C                   PARM                    RMTFIL           50
      *
     C                   PARM                    CMD1             20
     C                   PARM                    CMD2             20
     C                   PARM                    CMD3             20
     C/EJECT
      ********************************************************************
      * The Main Program                                                 *
      ********************************************************************
      *
     C                   EXSR      CF001
      *
     C                   EVAL      *INLR = *ON
     C                   RETURN
     C*
     C/EJECT
      ********************************************************************
      * S U B R O U T I N E S                                            *
      ********************************************************************
      ********************************************************************
      * Main Processing                                                  *
      ********************************************************************
     C     CF001         BEGSR
      *
     C                   Z-ADD     *ZERO         SEQ               6 2
      *
     C                   EXSR      CF002
     C                   EXSR      CF003
     C                   EXSR      CF004
     C                   EXSR      CF005
      *
     C                   ENDSR
     C/EJECT
      ********************************************************************
      * Build and Write User ID and Password record                      *
      ********************************************************************
     C     CF002         BEGSR
      *
     C                   Z-ADD     *ZERO         SRCDAT
     C                   ADD       1             SEQ
     C                   Z-ADD     SEQ           SRCSEQ
     C     RMTUSR        CAT(P)    RMTPWD:1      SRCDTA
     C                   WRITE     FTPCMD        CmdRec
      *
     C                   ENDSR
     C/EJECT
      ********************************************************************
      * Write Optional FTP command records                               *
      ********************************************************************
     C     CF003         BEGSR
      *
     C     CMD1          IFNE      *BLANK
     C                   Z-ADD     *ZERO         SRCDAT
     C                   ADD       1             SEQ
     C                   Z-ADD     SEQ           SRCSEQ
     C                   MOVEL(P)  CMD1          SRCDTA
     C                   WRITE     FTPCMD        CmdRec
     C                   ENDIF
      *
     C     CMD2          IFNE      *BLANK
     C                   Z-ADD     *ZERO         SRCDAT
     C                   ADD       1             SEQ
     C                   Z-ADD     SEQ           SRCSEQ
     C                   MOVEL(P)  CMD2          SRCDTA
     C                   WRITE     FTPCMD        CmdRec
     C                   ENDIF
      *
     C     CMD3          IFNE      *BLANK
     C                   Z-ADD     *ZERO         SRCDAT
     C                   ADD       1             SEQ
     C                   Z-ADD     SEQ           SRCSEQ
     C                   MOVEL(P)  CMD3          SRCDTA
     C                   WRITE     FTPCMD        CmdRec
     C                   ENDIF
      *
     C                   ENDSR
     C/EJECT
      ********************************************************************
      * Build and Write PUT/GET Command Record                           *
      ********************************************************************
     C     CF004         BEGSR
      *
     C                   Z-ADD     *ZERO         SRCDAT
     C                   ADD       1             SEQ
     C                   Z-ADD     SEQ           SRCSEQ
      *
     C                   SELECT
     C     FUNCTION      WHENEQ    'P'
     C     'PUT'         CAT(P)    LCLFIL:1      SRCDTA
     C     SRCDTA        CAT(P)    RMTFIL:1      SRCDTA
     C                   WRITE     FTPCMD        CmdRec
      *
     C     FUNCTION      WHENEQ    'G'
     C     'GET'         CAT(P)    RMTFIL:1      SRCDTA
     C     SRCDTA        CAT(P)    LCLFIL:1      SRCDTA
     C     SRCDTA        CAT(P)    '(Replace':1  SRCDTA
      *
      *
      *
      *
     C                   WRITE     FTPCMD        CmdRec
     C                   ENDSL
      *
     C                   ENDSR
     C/EJECT
      ********************************************************************
      * Build and Write QUIT Record                                      *
      ********************************************************************
     C     CF005         BEGSR
      *
     C                   Z-ADD     *ZERO         SRCDAT
     C                   ADD       1             SEQ
     C                   Z-ADD     SEQ           SRCSEQ
     C                   MOVEL(P)  'QUIT'        SRCDTA
     C                   WRITE     FTPCMD        CmdRec
      *
     C                   ENDSR

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.