Run Your FTP Using Batch Job

The FTP process that is run through an interactive job is quite worrying if the object we are going to transfer is quite large and takes a long time. If the terminal connection is lost or the pc/laptop hangs, the FTP process will terminated. Therefore, to keep the things above from happening, we can do the FTP process using a batch job.

In running FTP into a batch job, we can use a custom program. For example, I will create an FTP program using the CLP (Command Line Programming) program.

The structure that must be prepared in running the FTP program consists of:

  1. FTP Program used to run the FTP process.
  2. FTP Input File, as FTP command/instruction file. In the form of a member file, with TXT format.
  3. FTP Output Files, as FTP output log files. In the form of a member file, with TXT format.

I created the input and output files for example in the SAULSRC file in the SOOLGPL program with the member names FTPI for input and FTPO for output files.

CLP Program

Here’s a simple program to create an FTP process:

Copy the code below:

    PGM                                                               
            CLRPFM     FILE(SOOLGPL/SAULSRC) MBR(FTPO)                
OPNDBF:     OVRDBF     FILE(INPUT) TOFILE(SOOLGPL/SAULSRC) MBR(FTPI)  
            OVRDBF     FILE(OUTPUT) TOFILE(SOOLGPL/SAULSRC) MBR(FTPO) 
            FTP        RMTSYS('192.168.168.20')                       
            DLTOVR     FILE(INPUT OUTPUT)                             
            GOTO       CMDLBL(ENDPGM)                                 
ENDPGM:     ENDPGM                                                    

FTP Input (FTPI)

In the input file section, enter all stages of the FTP process, starting with entering the username and password for the server/transfer target as in the example above.

FTP Output (FTPO)

Next for FTP Output, just provide an empty member. This member will contain the FTP process log after the program is run. Example output file:

Related Link:

Leave a Reply