Question on parameter passing to ExecSH

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

Post Reply
shillaire
Participant
Posts: 1
Joined: Tue Oct 17, 2006 3:41 pm

Question on parameter passing to ExecSH

Post by shillaire »

Hi-

In building our data warehouse I have decided to use the ExecSH functionality for the Before-job and After-job subroutine.

As I will be adding this code to all of the jobs, I would like to be able to pass a variable to the script with the name of the job to simplify maintenance, for example: /call/some/script.sh JOB_NAME.

The closest I have gotten is this: /call/some/script.sh %JOBNAME% where %JOBNAME% is defined as a parameter with the text string of DSGetJobInfo(DSJ.ME,DSJ.JOBNAME).

Obviously, the text string is just that, a text string, and does not get evaluated to the value I want to pass to the script.

So, is there some built-in variable within the job that I can use or is there some way to force the evaluation of the parameter to get the result I want?

Thanks
Sam Hillaire
ray.wurlod
Participant
Posts: 54595
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard. :D

References to job parameters need to be encased in "#" characters, not "%" characters. There is no call command; ExecSH executes a UNIX command directly. Assuming you have execute permission to the script, try

Code: Select all

/some/script.sh #JOBNAME#

If you don't have execute but do have read permission, use . or source to execute the script (just as you would at a UNIX prompt).

Beware that job parameter names/references are case sensitive.

The script can pick the passed command line arguments up through the shell variables such as $1, $2 and so on.
Last edited by ray.wurlod on Fri Oct 20, 2006 2:36 pm, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Are you asking for some inherent variable that contains the job's name at runtime that you can use as an argument in a before/after routine call?

I guess you're trying to avoid embedding a hardcoded name and want one that automatically resolves at runtime? Search for using the macro DSJobName. You treat it like a parameter (use #'s) but it's really a macro.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Post Reply