How to assign job status into variable in shell programing

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
ragunathan13
Participant
Posts: 50
Joined: Mon Sep 25, 2006 11:18 pm
Location: Chennai
Contact:

How to assign job status into variable in shell programing

Post by ragunathan13 »

Hi....

I Run a DS Job in unix shell programing use "dsjob -run" command. After Execute this command i got "Status code = 0" like. I need to assign that Status code into a variable.

Thanks in advance.

Regards,
Ragunathan J
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What do you mean 'assign that Status code into a variable'? Do you mean have the script return that code as its exit status? Or just use it internally? How are you running a 'DS job in unix shell programming' if your server is on Windows? :shock:

Perhaps:

Code: Select all

dsjob -run blah-blah-blah
X=$?
exit $X
For whatever you'd like this X to actually be called. 'X' gets assigned the value of the status code returned by dsjob and then that is passed out as the exit status of the script as an added bonus.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ragunathan13
Participant
Posts: 50
Joined: Mon Sep 25, 2006 11:18 pm
Location: Chennai
Contact:

Post by ragunathan13 »

Hi chulett ,

i would like to thank for reply. we r running the dsjobs in the unix command window. It is return job status externally ,My Requirement: the corresponding output will assign as a user defined variable.

for example: i will run the shell progrmm and output of this program generate some status code. i want to assign that status code to a user defined variable like

A=staus code.

if is it possible to do this? if yes please give some idea regarding this.

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

Post by DSguru2B »

If you want the retrieve the status code of the dsjob command then do as Craig advised. And, if you want to retrieve the status code of the job then add -jobstatus to Craigs advised commands. i.e,

Code: Select all

dsjob -run -jobstatus blah-blah-blah 
X=$? 
exit $X
This way you will get a status code of 1 if job is successful, 2 if it finished with warnings, 3 if it aborted, yada yada yada.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

ragunathan13 wrote:if is it possible to do this? if yes please give some idea regarding this.
Pretty sure that's exactly what I gave you. :?

In my example, your A = my X, with X getting assigned the status code from the dsjob run. If that's not enough then you'll need to explain your problem a little better... like exactly where this assignment should be happening.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

When you use the -jobstatus option, the exit status of dsjob is the exit status of the job that was run. You need to know that for the efficacy of Craig's solution to be explained.
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