dsjob (status code)

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

DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

That is the job return code. When you stick in "-jobstatus" to your dsjob command, the status code will be the job return code. When you execute the dsjob command without the "-jobstatus", the command exit code will be returned.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
mystuff
Premium Member
Premium Member
Posts: 200
Joined: Wed Apr 11, 2007 2:06 pm

Post by mystuff »

Great Thanks for the help
mystuff
Premium Member
Premium Member
Posts: 200
Joined: Wed Apr 11, 2007 2:06 pm

Post by mystuff »

Code: Select all

eval dsjob -lognewest $Project $JobName | awk -F"\=" '{print $2}' | read EventId 
              if [ $? -ne 0 ] 
              then 
                  echo "Error." 
                  exit 2 
              fi 
.....Next command....... 
I still get the output Status Code=0
mystuff
Premium Member
Premium Member
Posts: 200
Joined: Wed Apr 11, 2007 2:06 pm

Post by mystuff »

Code: Select all

eval dsjob -lognewest $Project $JobName | awk -F"\=" '{print $2}' | read EventId 
              if [ $? -ne 0 ] 
              then 
                  echo "Error." 
                  exit 2 
              fi 
.....Next command....... 
I still get the output Status Code=0
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Thats fine, you can ignore that.
With the above code you are acomplising both, getting the event id and checking the status of your command.
The status code will still be spit out onto stdout, which is your screen. That shouldnt be of any concern, its harmless.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

$? is the exit status of the final command in the pipeline - in your case the read command. You need different logic to have the shell script exit with the value of the dsjob exit status.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Ray, does'nt 'eval' take care of that and treat the piped commands as a single command?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply