Page 2 of 2

Posted: Fri May 02, 2008 12:38 am
by ray.wurlod
It uses a lower level call than that, probably fopen() - but I don't know for sure.

Posted: Mon May 19, 2008 8:35 am
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.

Posted: Mon May 19, 2008 9:20 am
by chulett
That would be because you used single quotes rather than the 'back tick' that Jim's example showed.

Posted: Mon May 19, 2008 9:48 am
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...

Posted: Mon May 19, 2008 9:55 am
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.

Posted: Mon May 19, 2008 10:35 am
by vnspn
Thanks a lot Craig.

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

Thank you...

Posted: Mon May 19, 2008 4:57 pm
by ray.wurlod
Please mark the thread as Resolved.

Posted: Mon May 19, 2008 5:01 pm
by chulett
Not his thread, or I woulda asked the same. :wink:

Posted: Thu Jun 25, 2009 7:16 am
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.

Posted: Thu Jun 25, 2009 7:20 am
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.

Posted: Thu Jun 25, 2009 7:25 am
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.