Page 2 of 2
Posted: Thu Jul 02, 2009 7:03 am
by karthi_gana
priyadarshikunal wrote:After selecting ExecDOS you need to pass the command to execute in the text box in-front of it. so that the routine ExecDOS can execute it.
which command will give the current date?
My requirement is i have to add the current date at the end of the file.
if i run today then today's date, if i run tomorrow then tomorrow's date.
Posted: Thu Jul 02, 2009 7:04 am
by priyadarshikunal
use a move command in ExecDOS where the second parameter should be
Code: Select all
<filename>%date:~6,4%%date:~3,2%%date:~0,2%.txt
hope this helps.
Posted: Thu Jul 02, 2009 7:21 am
by karthi_gana
priyadarshikunal wrote:use a move command in ExecDOS where the second parameter should be
Code: Select all
<filename>%date:~6,4%%date:~3,2%%date:~0,2%.txt
hope this helps.
1) I have declared a variable in the Parameter like
Parameter DefaultValue
FileName MSDFF
2) I choosed 'ExecDOS' from after subroutine(Transformer stage).
3) I gave the below value in the INPUT VALUE combo box.
MOVE #FileName# MSDFF%date:~6,4%%date:~3,2%%date:~0,2%.txt
is this correct?
I got the below error message.
ALRT_A01..tr_xc (ExecDOS): Error when executing command: MOVE MSDFF MSDFF%date:~6,4%%date:~3,2%%date:~0,2%.txt
*** Output from command was: ***
The syntax of the command is incorrect.
Posted: Thu Jul 02, 2009 7:24 am
by Sainath.Srinivasan
* * REPOSTING * *
Try something like
Code: Select all
move yourFileName yourFileName#pCurrentDate#
where pCurrentDate is the date parameter formatted in required manner.
Posted: Thu Jul 02, 2009 7:44 am
by chulett
First off, you need to do it after job not after stage. Secondly, you need a valid DOS command for the task - use rename rather than move. Get it working from a cmd prompt then add it to the job.
Posted: Thu Jul 02, 2009 7:50 am
by priyadarshikunal
I cannot test it from datastage job as I am on unix box. But on command prompt
MOVE MSDFF MSDFF%date:~6,4%%date:~3,2%%date:~0,2%.txt
works fine and a file called MSDFF20090702.txt got created.
Posted: Thu Jul 02, 2009 8:01 am
by priyadarshikunal
if by any chance datastage is not allowing it to execute, create a job parameter pCurrentDate and from sequence job you can pass formatted date using combination of Date() and field() function.
and execute a rename command in after job ExecDOS using this parameter similar to Sainath's suggestion with Craig's suggestion implemented in it. something like
rename yourFileName yourFileName#pCurrentDate#
Posted: Thu Jul 02, 2009 8:05 am
by chulett
Technically, 'move' is for moving a file from one drive letter / location to another and 'rename' just renames a file in place. With a UNIX background you might gravitate to 'move' but 'rename' would be more appropriate even if the other can be made to work.
Posted: Thu Jul 02, 2009 8:09 am
by priyadarshikunal
@Craig
I agree.
@karthi_gana
Just noticed : where is the path?
you need to provide a fully qualified path of the file to run the command. Computer is not so intelligent to find that file for you before renaming or moving it.