I am looking for an approach / design through which i want to automate the process of FTP from windows location to IFS location present on AS400 environment when ever there is a new file added to windows path.
Below is the approach I thought, Please refine it if needed.
- We have an option
WRKJOBSCDE
through which we can run a CL program in a scheduled threshold of 1hr.
- To write a CL program which invokes a script(pyton/shell) to talk to windows location(say X:drive having its IP as xx.xxx.xx.xx).
- Shell script has to search for latest file in the location X:drive and FTP that jar(of size 5mb max) to IFS location(say /usr/dta/ydrive) on AS400 machine.
- Thus, CL program we invoked in STEP2 has to mail to me using
SNDDST
the list of all the jars ftp'd by the scheduler job that runs every 1 hr in STEP1.
All I am new to CL programming/RPGLE . Please help me with some
learning stuff and also design of such concepts.
You could use a library like the one provided by Scott Klement at https://www.scottklement.com/ftpapi/ to roll your own automation client. It was designed to be used from RPG, and is easy to use. From there it is a simple task to:
- retrieve a list of files in the directory
- parse the list to retrieve file timestamps
- get any files with a timestamp later than the last successful run
The CL command RUNRMTCMD can be used to invoke a command on a PC running a rexec() client. iSeries Access for Windows offers such a client, and there are others available. With the iSeries client, the output of the PC command is placed in a spool file on the AS/400, which should contain the results of the FTP session.
You can copy the spool file to a file using the CPYSPLF command and SNDDST it to yourself, but I am not sure the contents will be converted from EBCDIC to ASCII.
Check out Easy400.net for the MMAIL programs developed by Giovanni Perotti. This package includes an EMAILSPL command to email a spool file. I believe you will need to pay $50 for the download.
I think you are on the right track, but the are a lot of details.
You have to learn to program windows. dotnet filewatcher Out of scope for a complete answer. All of the other solutions seem to be polling solutions "Are we there yet?" "No were not there."