Runnig a script in datastage

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

mdtauseefhussain
Participant
Posts: 38
Joined: Mon Feb 27, 2006 10:34 pm
Location: Chennai
Contact:

Runnig a script in datastage

Post 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
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Re: Runnig a script in datastage

Post 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
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ps. That's not a script. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
mdtauseefhussain
Participant
Posts: 38
Joined: Mon Feb 27, 2006 10:34 pm
Location: Chennai
Contact:

Post by mdtauseefhussain »

I need to concatenate time stamp along with the date the file name should be like this

Sample20060713000000
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
shamshad
Premium Member
Premium Member
Posts: 147
Joined: Wed Aug 25, 2004 1:39 pm
Location: Detroit,MI

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

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

"You can never have too many knives" -- Logan Nine Fingers
mdtauseefhussain
Participant
Posts: 38
Joined: Mon Feb 27, 2006 10:34 pm
Location: Chennai
Contact:

Post 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
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post 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 
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Note that the date pattern components (a) are case sensitive and (b) are enclosed in (specifically) double quotes.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Though the point b given in Ray post doesnt give any big impact, the point a, is important.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

mdtauseefhussain wrote:i tried with concatenating %h%m%s
Yes, exactly - case sensitive. Who said anything about using '%h%m%s'? :P
-craig

"You can never have too many knives" -- Logan Nine Fingers
mdtauseefhussain
Participant
Posts: 38
Joined: Mon Feb 27, 2006 10:34 pm
Location: Chennai
Contact:

Post by mdtauseefhussain »

What if we want to bring the date format like this with file name

Sample 2006-07-14 22:25:30.txt
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post 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.
Last edited by DSguru2B on Fri Jul 14, 2006 7:36 am, edited 1 time in total.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Then put spaces where you want spaces and colons where you want colons. How hard is this to figure out? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
mdtauseefhussain
Participant
Posts: 38
Joined: Mon Feb 27, 2006 10:34 pm
Location: Chennai
Contact:

Post by mdtauseefhussain »

Sorry guys iam very new to unix and datagstge ,please forgive me if iam asking silly questions
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
Post Reply