Page 1 of 1

Sequential file name with Timestamp

Posted: Thu Nov 11, 2010 6:40 am
by mac4rfree85
Hi Guys,

I need to create a sequential file with the name as macDDMM.txt where DD is day and MM is the month.
I thought of two ways to do it. But both of them does not suits me.
One is through Sequence where you can use the Unix command mv. But sequence is needed only for this. So, i want to avoid it unless there is no other way.
Second is through a parameter and passing it to the filename. But i do not have the previlages to create parameters.

Can anybody help me in accomplish this in some other way.

Regards,
Magesh

Posted: Thu Nov 11, 2010 6:44 am
by chulett
Those are the two ways but you don't need a Sequence job for the first, it can be done 'after job' using ExecSH.

Posted: Thu Nov 11, 2010 6:46 am
by mac4rfree85
thanks chulett for the quick reply..
I missed it..

Posted: Thu Nov 11, 2010 7:50 am
by mac4rfree85
I am getting an error with ExecSH.
This is what i gave
After-Job Routine : ExecSH
Input Value : mv Rej.txt Rej`date +'%m%d'`.txt

The mv command is working fine which i have tested it.
AFter the run, i am able to find the Rej.txt also which was created by the job.

Can anybody shed some light on where i am going wrong.

Thanks for your help in advance.

Posted: Thu Nov 11, 2010 7:52 am
by mac4rfree85
This is what i got from director.

.AfterJob (ExecSH): Error when executing command: mv Rej.txt Rej`date +'%m%d'`.txt
*** Output from command was: ***
mv: cannot access Rej.txt

Posted: Thu Nov 11, 2010 8:18 am
by ArndW
The working directory of the DataStage job and thus for any shells called from it is the DataStage project directory - so you should put an absolute path in for any file operations to make sure that they are correctly addressed at runtime.

Posted: Thu Nov 11, 2010 8:37 am
by chulett
Right, a full path not a relative path. That or 'cd' there first:

Code: Select all

cd target_directory && mv old new

Posted: Thu Nov 11, 2010 9:22 am
by mac4rfree85
Thanks guys,, cudn test it though.. but i think i got it...

Posted: Fri Nov 12, 2010 5:34 am
by mac4rfree85
tested it succesfully.. tat fixed it..