FTP stage to retrieve the lastest file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ysweec
Participant
Posts: 31
Joined: Thu Jun 17, 2004 9:01 pm

FTP stage to retrieve the lastest file

Post by ysweec »

Hi all,

Can FTP stage be used to retrieve the lastest file from a server?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Define 'latest file'. :?

I'm sure you can make use of the FTP stage for something like this, but since it cannot handle multiple files (or even wildcards as far as I recall) you'll need to know which file you want before you get to the stage in your jobstream.

You'd need to script something to go out to the remote server and find the latest version of the file you are looking for, capture the filename and then pass it into your job as a Job Parameter. While you're there, you might as well script the FTP part as well and 'get' the file at the same time. Then you can simply process the file in your job.

My two cents. I'm sure others will be along with different approaches. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You could, in the FTP stage, use a "before" command uniquely to identify the latest file and give it a fixed name that FTP could use. Something like:

Code: Select all

rm -rf mytempdir && mkdir mytempdir && cp `ls -t | head -1` mytempdir/xyz && cd mytempdir
then use FTP to get the xyz file
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply