Capture the jobstatus

Archive of postings to DataStageUsers@Oliver.com. This forum intended only as a reference and cannot be posted to.

Moderators: chulett, rschirm

Locked
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Capture the jobstatus

Post by admin »

Hello,

I am trying to write a batch file. In this file, I will first submit a datastage job using datastage command line similar to this:

~dsjob.exe [bunch of parameters] -run -jobstatus projectname jobname

Depends on the status of this job, I will decide what to do next in the batch file, such as if its sucessfull, continue with the following tasks or else exit.

My question is how do I capture the jobstatus code so that I can use it in the condition statement?

Thanks in advance,

Hong-ching
admin
Posts: 8720
Joined: Sun Jan 12, 2003 11:26 pm

Post by admin »

Here are a few different ways. I hope one might help.

>RTN=`dsjob -run -jobstatus Project JobName`
Finished waiting for job

Status code = 1
>echo $RTN
Waiting for job... Job Status : (1)
>

Note: If job fails because of bad parameter or the like RTN will be blank.

--- Or ---
dsjob -run -jobstatus -param ToDSN=asdf Project JobName 2>foo
>fgrep Status foo|cut -d" " -f4
-10
>

--- Or --- this can be found in the Job Developers Guide.

Displaying Job Information
The following syntax displays the available information about a specified
job:
dsjob -jobinfo project job
project is the name of the project containing job.
job is the name of the job.
The following information is displayed:
* The current status of the job
* The name of any controlling job for the job
* The date and time when the job started
* The wave number of the last or current run (internal DataStage reference number) *User status This syntax is equivalent to the DSGetJobInfo function.

--- Or ---
In Perl you would do something like:
# Check status of the job
@dsreturn=`dsjob -jobinfo $Project1 $Job1`;

# Evaluate the return code from the process
if ($? == 0) {
chop (@dsreturn);

# Evaluate the DataStage return variable
if ($dsok=grep(/RUN OK/, @dsreturn)) {
print "nCompleting successful run of job: $Job1 ...$dsokn";
}
else {
print ("nnError processing DataStage Job: $Job1nn");

--- Or ---
Within DataStage it is something like:
Status = DSGetJobInfo(hJobs(I), DSJ.JOBSTATUS)
Begin Case
Case Status = DSJS.RUNFAILED
Call DSLogWarn("Job Failed: " :Jobs(I,1), "JobControl")
Jobs(I,3) = "FAIL"
GetInfo = 1
STOPPROG = 1
Case Status = DSJS.RUNWARN
Call DSLogWarn("Job Finished with Warning: " :Jobs(I,1),
"JobControl")
Jobs(I,3) = "WARN"
GetInfo = 1
Case Status = DSJS.RUNOK
Call DSLogInfo("Job Finished Successfully: " :Jobs(I,1),
"JobControl")
Jobs(I,3) = "OK"
GetInfo = 1
Case @True
Call DSLogWarn("Must reset " :Jobs(I,1) :" before it can run.", "JobControl")
Jobs(I,3) = "RESET"
GetInfo = 0
End Case


-----Original Message-----
From: HongqingTang [mailto:HTang@harlandfs.com]
Sent: Thursday, August 23, 2001 11:58 AM
To: datastage-users@oliver.com
Subject: Capture the jobstatus


Hello,

I am trying to write a batch file. In this file, I will first submit a datastage job using datastage command line similar to this:

~dsjob.exe [bunch of parameters] -run -jobstatus projectname jobname

Depends on the status of this job, I will decide what to do next in the batch file, such as if its sucessfull, continue with the following tasks or else exit.

My question is how do I capture the jobstatus code so that I can use it in the condition statement?

Thanks in advance,

Hong-ching
***Note:The information contained in this message may be privileged and confidential and protected from disclosure. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the Sender immediately by replying to the message and deleting it from your computer. Thank you. Premier Inc.
Locked