calling scripts using Execsh

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

calling scripts using Execsh

Post by pxraja »

Hi All,

I want to know how to call the shell script using ExecSH (before job subroutine)

my script is in the path /opt/IBM/test.ksh

Also i want to find the materials regarding the commands for ExecTCL that can be used in datastage.

any suggestions and guidance will be most welcome.

thanks in advance
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Put the pathname of the script in the Input Values field.

You can execute any valid UNIX command (though some would, of course, be unwise, such as halting the machine).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Exactly, simply put the full path to the script in the Input Values field along with any parameters if needed. And you can use job parameters in any portion of that. If needed.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

chulett wrote:Exactly, simply put the full path to the script in the Input Values field along with any parameters if needed. And you can use job parameters in any portion of that. If needed. ...
In my script I am saving the wordcounts of CSV files to /opt/IBM/count_<<yesterdays date>.txt and i need to call this as the input file in the sequential stage.

seq.stage--->Trf---->ODBC.Stage.

i want to use before sub routine and the script will give me the file in the above format. but i want to know how to call this file as a input without hardcoding.

thanks for suggestion.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Pass in yesterday's date as a job parameter. Use it in both the ExecSH call and the Sequential File stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
pxraja
Participant
Posts: 142
Joined: Fri Mar 14, 2008 10:22 am

Post by pxraja »

chulett wrote:Pass in yesterday's date as a job parameter. Use it in both the ExecSH call and the Sequential File stage. ...
thanks for your reply, but I need some more input on how to get previous date as the parameter

please trigger some ideas

I can get yesterday's date in a stagevariable using the code:

Oconv(@DATE-1,'DYMD[2,2,2]') -----> Prevday;

But how to get the above in a job parameter?
Pagadrai
Participant
Posts: 111
Joined: Fri Dec 31, 2004 1:16 am
Location: Chennai

Post by Pagadrai »

pxraja wrote: I can get yesterday's date in a stagevariable using the code:
Oconv(@DATE-1,'DYMD[2,2,2]') -----> Prevday;
But how to get the above in a job parameter?
How are you calling this job?
if you are using a sequence, you can use 'user variables' stage to get the date and use this as input to your job parameter.
sbass1
Premium Member
Premium Member
Posts: 211
Joined: Wed Jan 28, 2009 9:00 pm
Location: Sydney, Australia

Post by sbass1 »

pxraja wrote: In my script I am saving the wordcounts of CSV files to /opt/IBM/count_<<yesterdays date>.txt and i need to call this as the input file in the sequential stage.

seq.stage--->Trf---->ODBC.Stage.

i want to use before sub routine and the script will give me the file in the above format. but i want to know how to call this file as a input without hardcoding.

thanks for suggestion.
Another approach is to call your script as a filter in the sequential stage. Your script should write to STDOUT, rather than to a file. The sequential stage then reads STDOUT as though it were the input file.

If you need yesterday's date, get it from the O/S in your script.

See the doc on sequential stages, filter command for more details.

HTH,
Scott
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

This same script that creates the file with yesterday's date can also land that date for you in a flat file. Then a Sequence job can use 'cat' to capture that and easily pass the value on as a parameter to your job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply