How can I trap the status from dsjob?

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
videsh77
Premium Member
Premium Member
Posts: 97
Joined: Thu Dec 02, 2004 10:43 am
Contact:

How can I trap the status from dsjob?

Post by videsh77 »

1. I dont want to run a job, if it is in aborted state. I need to trap this before executing 'dsjob' from command prompt.

2. Also, I want to detect that job have been completed successfully, & need to trap that code, that the job has finished.

Can anyone has idea, how we can achieve this?
Thanks with regards,
videsh.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

First call is to dsjob with -jobinfo. This returns the status. You can then make the decision about whether to use the -run option (perhaps with run mode RESET?).
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 »

In other words, a shell script 'wrapper' that does all this before actually running the job for real. All kinds of checking can go on.

As Ray noted, first thing is to use -jobinfo to check the current status of the job - including if it even exists. If the job needs to be reset, another call to dsjob with the -run -mode RESET that Ray mentioned will do the trick.

Running the job with the -wait option will cause the command to wait until the job finishes before moving to the next step. I prefer using the -jobstatus option instead as it does the same waiting but returns 'DataStage codes': 1 = Ok, 2 = Warnings, 3 = Aborted, etc.

We also shift through the parameters passed to the wrapper script to build the appropriate -param statements the job may need.

Try running jobs with various variations of these commands yourself from the command line so you'll become familiar with what they return, good and bad. That way you'll know what to trap. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
videsh77
Premium Member
Premium Member
Posts: 97
Joined: Thu Dec 02, 2004 10:43 am
Contact:

Post by videsh77 »

Chulette

I am not able to locate -jobstatus, as an option to dsjob. Let me share the command what I gave :

dsjob -server $server -user $user -password $password -jobstatus DSRepName DSJobName

I am getting - Invalid/unknown primary command switch.

We have requirement, to wait until job finishes & retirieve the status.
Thanks with regards,
videsh.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

The -jobstatus option is used as a suboption with the -run main option. The actual option you require is -jobinfo.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
videsh77
Premium Member
Premium Member
Posts: 97
Joined: Thu Dec 02, 2004 10:43 am
Contact:

Post by videsh77 »

Thank you very much.
Thanks with regards,
videsh.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

This is actually what Craig said, if you re-read his post carefully. :wink:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply