iSeries Batch FTP using CL programming

Here are the steps to FTP multiple files in batch mode

1) Create an empty member in a source physical file say FTP_RES to receive response log after FTP is complete.

Member      Type        Text                           
FTP_RES     TXT         FTP Response File

2) Create another member in a source physical file say FTP_REQ to input FTP instructions. Here is a sample file
Member      Type        Text                           
FTP_REQ     TXT         FTP Request File

{user_id} {password}                                                   
na 1                                                         
put /{ifs_dir}/{ifs_sub_dir}/{filename1.ext} /{remote_dir}/{filename2.ext }
get  /{remote_dir}/{filename1.ext } /{ifs_dir}/{ifs_sub_dir}/{filename2.ext} (replace

na 0
put {library}/{filename1} {remote_library}/{filename2}

get  {remote_library}/{filename1} {library}/{filename2} (replace

The dots mean put more file like the syntax above. Anything within the curly braces{} needs to be replaced with actual values. filename1 and filename2 can be same name. na means naming format. na 1 is used for IFS like directory structure and na 0 used for regular iSeries objects. bin means binary data change it to ascii if your are sending text data.

3) Create the CL program to do the FTP. Here is a sample file
             OVRDBF     FILE(INPUT)  TOFILE(*LIBL/{source_file}) MBR(FTP_REQ)    
             OVRDBF     FILE(OUTPUT) TOFILE(*LIBL/{source_file}) MBR(FTP_RES)   
             FTP        RMTSYS({host_name or IP Address})                      

4) The END!

Recommended Reading

No comments:

Post a Comment

NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.