Sequential file name with Timestamp

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
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Sequential file name with Timestamp

Post 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
Mac4rfree
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

thanks chulett for the quick reply..
I missed it..
Mac4rfree
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post 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.
Mac4rfree
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post 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
Mac4rfree
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Right, a full path not a relative path. That or 'cd' there first:

Code: Select all

cd target_directory && mv old new
-craig

"You can never have too many knives" -- Logan Nine Fingers
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

Thanks guys,, cudn test it though.. but i think i got it...
Mac4rfree
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

tested it succesfully.. tat fixed it..
Mac4rfree
Post Reply