File nane with date

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

ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It uses a lower level call than that, probably fopen() - but I don't know for sure.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

jhmckeever wrote:If your concern with the Unix option is that you don't want another 'asset' to have to manage outside the DataStage environment then couldn't you just supply the 'script' in the filename specification?

E.g. Something like ...

Code: Select all

MyFilename_`date +%Y%m%d-%H%M%S`.txt
I've been working in a purely PX environment for quite some time and don't remember if this will work in server - so apologies in advance if it's not appropriate to your environment.

John.
Hi,

We tried this method to create the file with date appended to the filename. But, the output filename we got was a string without the actual date. The output we got was,
MyFilename_'date +%Y%m%d'.txt

The date function did not return the actual date. But, instead 'date' as such was part of the filename. Our server is Linux. We tried manually executing the command "date +%Y%m%d" in command line and this correctly returns the date.

Could you please tell us what kind of change that we have to do to get the date from the format that is mentioned.

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That would be because you used single quotes rather than the 'back tick' that Jim's example showed.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

Thanks Craig.

I changed it to 'back tick' and ran and still its not working. I tried creating the file using this through command line and that worked. But when I give this expression within the stage in DS, it does not work. Any idea...
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That can't be used in directly in the stage AFAIK. You'd need to create a fixed filename and then use that 'after job' via ExecSH to rename the file to include the date.
-craig

"You can never have too many knives" -- Logan Nine Fingers
vnspn
Participant
Posts: 165
Joined: Mon Feb 12, 2007 11:42 am

Post by vnspn »

Thanks a lot Craig.

I did it the way you said in After-job ExecSH. It worked.

Thank you...
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Please mark the thread as Resolved.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not his thread, or I woulda asked the same. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
prasad v
Participant
Posts: 174
Joined: Mon Mar 30, 2009 2:18 am

Post by prasad v »

jhmckeever wrote:Using the 'script' approach I outlined previously you can specify your own date format. E.g. DD_MM_YYYY would be ...

Code: Select all

MyFilename_`date +%d_%m_%Y`.csv
What are the criteria for incrementing the version number? Every job run? If so, you could store the value in an environment variable and use a before-Job ExecSH to increment it ...

Code: Select all

MYVAL=`expr $MYVAL + 1`
Then refer to that environment variable in your filename specification:

Code: Select all

MyFilename_`date +%d_%m_%Y_$MYVAL`
There are other approaches which I'm sure other posters will provide if needed.

John.


Hi

I tried as you told in this. But it's not working.
File name coming like this
MyFilename_`date +%d_%m_%Y_$MYVAL`
what i did is

I created environment variable in Parameters page. MYVAL and default value is 0
in General page. i selected EXECSh in before routine with the code
MYVAL=`expr $MYVAL + 1`
and the file name is given like
MyFilename_`date +%d_%m_%Y_$MYVAL`
Also i tried with only date
MyFilename_`date +%d_%m_%Y
this also not working file name coming as it is .

Could any one please suggest to solve the issue.
prasad v
Participant
Posts: 174
Joined: Mon Mar 30, 2009 2:18 am

Post by prasad v »

chulett wrote:That can't be used in directly in the stage AFAIK. You'd need to create a fixed filename and then use that 'after job' via ExecSH to rename the file to include the date. ...
can you please give me the code which i can put it in after job routine.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Since you hijacked this thread instead of starting your own, we have no idea what O/S you have. For UNIX, it's just the "mv" command with the date added as already shown.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply