How to call a .ksh from a before/after routine

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
dcguuenther
Participant
Posts: 13
Joined: Wed Feb 08, 2006 3:06 pm
Location: Chicago

How to call a .ksh from a before/after routine

Post by dcguuenther »

Hello.

I have written a .ksh script which will invoke several dsjob commands, but in general, it will accept project name, job name, email address as its arguments, and will retrieve the job log and email the job log, as well as any dependent job in an aborted states log to the email.

I currently run this on demand, however I would like to find a simple way to automate this when a job fails. I would like to use a before/after job routine on my top level sequencer that will perform this when the sequencer finishes. I'd rather use this then an execute command stage.

I am sure I can figure out how to code a routine, but would prefer not to have to read the docs on all of the available functions. Does anyone know which function I would call from my routine in order to invoke the .ksh.

in general, I want to envoke the below

#SCRIPT_DIR#/#SCRIPT_NAME# #PROJ_NAME#, #JOB_NAME#, #EMAIL#

which could translate to /home/job_retrieval.ksh Proj_1 Job_1 anyone@email.net

Thanks
mohdsuf
Participant
Posts: 24
Joined: Mon Jun 18, 2007 3:21 am
Location: India

Post by mohdsuf »

Hello,
In the job properties in general section, from "After job subroutine" select
ExecSH and in the input value put the below hashed words where the capital letter words are the job parameters.
#SCRIPT_DIR#/#SCRIPT_NAME# #PROJ_NAME#, #JOB_NAME#, #EMAIL#
Sufiyan
dcguuenther
Participant
Posts: 13
Joined: Wed Feb 08, 2006 3:06 pm
Location: Chicago

Post by dcguuenther »

Boom!!! Gosh that is simple. Thanks a ton.
mohdsuf
Participant
Posts: 24
Joined: Mon Jun 18, 2007 3:21 am
Location: India

Post by mohdsuf »

remove commas from this also
#SCRIPT_DIR#/#SCRIPT_NAME# #PROJ_NAME#, #JOB_NAME#, #EMAIL#
Sufiyan
dcguuenther
Participant
Posts: 13
Joined: Wed Feb 08, 2006 3:06 pm
Location: Chicago

Post by dcguuenther »

After Job Routine only seems to be available from a job, not a sequencer. Is that correct?

I really don't want to use ExecSh script from Sequencer since the job log will not be complete because the job is still running. Is my only choice to call this from the aix script that runs the job?
mohdsuf
Participant
Posts: 24
Joined: Mon Jun 18, 2007 3:21 am
Location: India

Post by mohdsuf »

If you want to use your script after job sequencer in a SEQUENCE job then you can use it with the help of ROUTINE ACTIVITY(RA) stage . Just place RA after the sequencer stage , choose ExecSH from the drop down routine name.
In the input argument column

use this
SCRIPT_DIR:"":SCRIPT_NAME:" ":PROJ_NAME:" ":JOB_NAME:" ":EMAIL:

When you run the job then for parameter SCRIPT_DIR
give path name as /dir1/dir2/
Make sure you give the last forward slash '/', which will consider the SCRIPT_NAME after that in one complete path and your other parameters as argument of the shell script.

Try this.
Sufiyan
Post Reply