Page 1 of 1

calling scripts using Execsh

Posted: Thu Apr 09, 2009 4:54 am
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

Posted: Thu Apr 09, 2009 7:28 am
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).

Posted: Thu Apr 09, 2009 8:05 am
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.

Posted: Fri Apr 10, 2009 4:35 am
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.

Posted: Fri Apr 10, 2009 7:15 am
by chulett
Pass in yesterday's date as a job parameter. Use it in both the ExecSH call and the Sequential File stage.

Posted: Mon Apr 13, 2009 1:22 am
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?

Posted: Mon Apr 13, 2009 3:31 am
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.

Posted: Mon Apr 13, 2009 4:19 am
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

Posted: Mon Apr 13, 2009 7:44 am
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.