1-get all files frome remote folder using sftp
2-put those file in my local folder
3-loop files in my local folder by date and pattern (example : Loop–get files which name like yyyy-dd-mm_name.txt and yyyy-dd-mm correspond to the older date–)
4-get data from file and execute some services
5-remove files frome remote folder
6-move files frome local folder to archive
[b]Any suggestion or help how to proceed would be greatly apprecaited.
see following code snippet (partially Pseudo-Code (might be incomplete regarding StreamToString transfortmations etc.)):
pub.client.sftp:login
pub.client.sftp:ls
LOOP Start
pub.client.sftp:get
pub.file:writeToFile
pub.client.sftp:rm
LOOP End
pub.client.sftp:logout
Get File-List according to Pattern
LOOP Start
pub.file:getFile
execute logic
pub.file:delete
LOOP End
Remember to update WmPublic/config/fileAccessControl.cnf with the path to your localFolder and reload the Packages to use the pub.file:*-Services.
what I mean is when you use ls command you will get file names in that directory ( Use ls to get files of that pattern) and re-direct to some file, see below one.
ls > FileNames.txt
Now you have all file details in FileNames.txt. Now loop over this file and perform your business logic.
ls all files thas respect a specific pattern
and move returned files(respecting pattern) of ls command to my local folder, and then get one by one using theire date of modification.
and finnaly use the content of each file : i dont have proble with this step.
here is the description from the IS Build-In-Services Guide for pub.client.sftp:ls:
There is no need to redirect the Output of ls to a new file, the service will return a list of matching files in parameter dirList.
You can use this List for your loop.
but i need to use the content of each file returned by ls, the content dosnt returned by ls???
and copy every filed returned by ls to local folder
ps: idon’t find yet how to use ls with pattern date , when i do namefile* it work good but its not what i need, what i need is to do like shell command : ls namefile which respect general pattern name_yyyy-mm-dd.txt
please check the pseudo code from my first post (meanwhile corrected with ls instead of list).
What will be the value of yyyy-mm-dd when executing ls?
If this cannot be provided to ls during runtime (i.e. 2016-01-25) you will have to do a branch inside the loop to see if the current filename from the list matches the pattern or not. If not just skip it, if yes read from remote and write to local.
thats exactly what i did for the first step but i dont know what to don in remotefile of get,
for the pattern could you please show me how to use branche to test if the pattern match or not,
attatched my code
Regards,
thats exactly what i did for the first step but i dont know what to don in remotefile of get,
for the pattern could you please show me how to use branche to test if the pattern match or not,