Page 1 of 2

Runnig a script in datastage

Posted: Thu Jul 13, 2006 9:06 am
by mdtauseefhussain
I have a script for renaming the file ,when iam running the script in Unix command prompt it working fine,but when iam runing in Datastage
After job subroutine on ExecSH it is throwing error

The script is
mv /data/datastage/Data/EMEA/sampleV.txt /data/datastage/Data/EMEA/sampleV$(date '+%Y%m%d')".txt"

Plaese help me out

Re: Runnig a script in datastage

Posted: Thu Jul 13, 2006 9:15 am
by DSguru2B
You dont $. Thats to reference it inside the script. And note date is surrounded by ` and not '(quote). Just copy paste my code in the execsh.

Code: Select all

mv /data/datastage/Data/EMEA/sampleV.txt /data/datastage/Data/EMEA/sample`date +"%Y%m%d"`.txt

Posted: Thu Jul 13, 2006 9:20 am
by chulett
ps. That's not a script. :wink:

Posted: Thu Jul 13, 2006 10:07 pm
by mdtauseefhussain
I need to concatenate time stamp along with the date the file name should be like this

Sample20060713000000

Posted: Thu Jul 13, 2006 10:56 pm
by shamshad
Use this example to make your command. You can change the date parameter to get the correct verion. The below example adds only dates to the file

mv dmi2.txt /global/site/vendor/Datastage/io/output/dmi3_$(date +'%d%m%Y').txt

Posted: Thu Jul 13, 2006 11:09 pm
by chulett
mdtauseefhussain wrote:I need to concatenate time stamp along with the date
If you are trying to say that you don't know how to add a time portion to the already provided date solutions, it's just this:

Code: Select all

%H%M%S

Posted: Fri Jul 14, 2006 1:26 am
by mdtauseefhussain
i tried with concatenating %h%m%s but iam getting the output as

"FileTestSort20060713Jul07%s" the time stam part is not coming properly

Posted: Fri Jul 14, 2006 3:21 am
by kumar_s
For these unix comand help, type

Code: Select all

>man date 
from your unix command prompt. You will have the possible list of attibutes and parameters that need to be passed.

For HP-UX that I tried, gave me the following.

Code: Select all

>date "+%Y%m%d%H%M%S"
20060714191923 

Posted: Fri Jul 14, 2006 5:42 am
by ray.wurlod
Note that the date pattern components (a) are case sensitive and (b) are enclosed in (specifically) double quotes.

Posted: Fri Jul 14, 2006 6:35 am
by kumar_s
Though the point b given in Ray post doesnt give any big impact, the point a, is important.

Posted: Fri Jul 14, 2006 6:57 am
by chulett
mdtauseefhussain wrote:i tried with concatenating %h%m%s
Yes, exactly - case sensitive. Who said anything about using '%h%m%s'? :P

Posted: Fri Jul 14, 2006 7:14 am
by mdtauseefhussain
What if we want to bring the date format like this with file name

Sample 2006-07-14 22:25:30.txt

Posted: Fri Jul 14, 2006 7:17 am
by DSguru2B
It has a space in between. Who keeps a space in a unix file.
If you do, then good luck in opening it.

Posted: Fri Jul 14, 2006 7:27 am
by chulett
Then put spaces where you want spaces and colons where you want colons. How hard is this to figure out? :?

Posted: Fri Jul 14, 2006 7:56 am
by mdtauseefhussain
Sorry guys iam very new to unix and datagstge ,please forgive me if iam asking silly questions