Page 1 of 1

Question on parameter passing to ExecSH

Posted: Fri Oct 20, 2006 2:14 pm
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

Posted: Fri Oct 20, 2006 2:29 pm
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.

Posted: Fri Oct 20, 2006 2:34 pm
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.