capture -jobinfo result in windows batch

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
Juls
Participant
Posts: 51
Joined: Tue Sep 14, 2004 9:17 am

capture -jobinfo result in windows batch

Post by Juls »

Hi,
I created a batch file in windows that runs a DS job. I want to check the status of the job and then decide whether a reset is needed. I am having trouble capturing and reusing the result of the status in a variable. Here is my code:

REM GET status info
%DSJOBPATH%\dsjob -jobinfo %PROJECT% %DSJOB%

how do I capture and reuse the result of above in an if statement.
This line DOES NOT WORK:
JOB_STATUS=%DSJOBPATH%\dsjob -jobinfo %PROJECT% %DSJOB%

Thanks,
Juls.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Redirect the output to a file, then check the file.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Juls
Participant
Posts: 51
Joined: Tue Sep 14, 2004 9:17 am

Post by Juls »

chulett wrote:Redirect the output to a file, then check the file. ...
Thanks, do you, by chance, have a sample how to check the file, how do I parse it?
Here is what the file has:
Job Status : RUN OK (1)

Job Controller : not available

Job Start Time : Tue Apr 15 11:24:43 2008
Job Wave Number : 7

User Status : not available

Job Control : 0

Interim Status : NOT RUNNING (99)

Invocation ID : not available

Last Run Time : Tue Apr 15 11:25:08 2008
Job Process ID : 0

Invocation List : seq_STAGING
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

For UNIX, sure. Under Windows? Nope, sorry, my DOS days are well and truly behind me.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What exact information are you looking for? Just to know if the job is aborted? I use grep for that in a shell script, something like this:

Code: Select all

eCount=`grep '(3)' /tmp/dsjob$$.out |wc -l`
if [ $eCount -eq 1 ] ;then
  echo "Job is aborted and must be reset..."
  <run reset>
I just have no clue how to do this in a batch without the MKS Toolkit, if you have that available you can do shell scripting rather than a batch file, from what I understand.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply