Page 1 of 1

Unix Return Code

Posted: Thu Apr 24, 2008 12:48 pm
by msacks
Hi-

I tried searching for an answer here for this without luck. I'm still new to DataStage so please bear with me.

I have a DataStage Sequence I'm trying to get to work. The first stage in the sequence is an Execute Command stage (named Execute_Command_0). This stage executes a shell script on the UNIX server, which will set a return code to eiher zero or one. The Execute Command stage has two triggers, the first has Expression Type "OK - Conditional", the other has "Custom - Conditional". The problem is with the "Custom - Conditional". I have the expression in the trigger for this as follows:

Execute_Command_0.$ReturnValue = '1'

When I execute the job it aborts with the error messages below. But since I'm explicitly testing for this return code I'm not sure why DataStage is treating this as an Unhandled Failure. I also tried changing the Expression Type for the trigger to ReturnCode - Conditional, and setting the Expression to 1, but that also didn't work. I also tried changing the Expression to '1' and "1" which also didn't work.


In Director I see the following Warnings:

WARNING
checkWeekTest..JobControl (@Execute_Command_0): Command /sbin/sh /home/dsadm/scripts/checkWeek.sh did not finish OK, reply = '1'

WARNING
checkWeekTest..JobControl (@Execute_Command_0): Controller problem: Unhandled failure (1) encountered executing command /sbin/sh /home/dsadm/scripts/checkWeek.sh

INFO
checkWeekTest..JobControl (@Coordinator): Summary of sequence run
14:27:14: Sequence started (checkpointing on)
14:27:14: Execute_Command_0 (COMMAND /sbin/sh /home/dsadm/scripts/checkWeek.sh) started
14:27:15: Execute_Command_0 finished, reply=1
14:27:15: Exception raised: @Execute_Command_0, Unhandled failure (1) encountered executing command /sbin/sh /home/dsadm/scripts/checkWeek.sh
14:27:15: Sequence failed (restartable)

FATAL
checkWeekTest..JobControl (fatal error from @Coordinator): Sequence job (restartable) will abort due to previous unrecoverable errors


Any help would be greatly appreciated!!

Re: Unix Return Code

Posted: Thu Apr 24, 2008 1:43 pm
by priyadarshikunal
msacks wrote:Hi-

I tried searching for an answer here for this without luck. I'm still new to DataStage so please bear with me.

I have a DataStage Sequence I'm trying to get to work. The first stage in the sequence is an Execute Command stage (named Execute_Command_0). This stage executes a shell script on the UNIX server, which will set a return code to eiher zero or one. The Execute Command stage has two triggers, the first has Expression Type "OK - Conditional", the other has "Custom - Conditional". The problem is with the "Custom - Conditional". I have the expression in the trigger for this as follows:

Execute_Command_0.$ReturnValue = '1'

When I execute the job it aborts with the error messages below. But since I'm explicitly testing for this return code I'm not sure why DataStage is treating this as an Unhandled Failure. I also tried changing the Expression Type for the trigger to ReturnCode - Conditional, and setting the Expression to 1, but that also didn't work. I also tried changing the Expression to '1' and "1" which also didn't work.


In Director I see the following Warnings:

WARNING
checkWeekTest..JobControl (@Execute_Command_0): Command /sbin/sh /home/dsadm/scripts/checkWeek.sh did not finish OK, reply = '1'

WARNING
checkWeekTest..JobControl (@Execute_Command_0): Controller problem: Unhandled failure (1) encountered executing command /sbin/sh /home/dsadm/scripts/checkWeek.sh

INFO
checkWeekTest..JobControl (@Coordinator): Summary of sequence run
14:27:14: Sequence started (checkpointing on)
14:27:14: Execute_Command_0 (COMMAND /sbin/sh /home/dsadm/scripts/checkWeek.sh) started
14:27:15: Execute_Command_0 finished, reply=1
14:27:15: Exception raised: @Execute_Command_0, Unhandled failure (1) encountered executing command /sbin/sh /home/dsadm/scripts/checkWeek.sh
14:27:15: Sequence failed (restartable)

FATAL
checkWeekTest..JobControl (fatal error from @Coordinator): Sequence job (restartable) will abort due to previous unrecoverable errors


Any help would be greatly appreciated!!

Here for any stage if returns anything else than 0 then it is a error for datastage.

Since your execute command stage is returning 1 means it failed to execute.

Can you run it with a true condition so that it returns 0

if it runs then try not to get the value you are getting from 'Return Value'

try getting it from 'command output' option.

then don't forget to parse it correctly.

Posted: Thu Apr 24, 2008 1:50 pm
by msacks
Thanks for the response. I already know that if the shell script exits with return code zero the sequence will not abort. DataStage allows me to create a trigger and create my own custom Exception handling, so it should be able to handle a return code other than zero and let me programatically deal with it. Any one else out there have any thoughts on this?

Posted: Thu Apr 24, 2008 2:34 pm
by filename.txt
Please try using option

Triggers > Expression Type > ReturnValue-(conditional)=1

instead of using custom-(conditional)

Posted: Thu Apr 24, 2008 2:36 pm
by filename.txt
Please try using option

Triggers > Expression Type > ReturnValue-(conditional)=1

instead of using custom-(conditional)

Posted: Thu Apr 24, 2008 2:36 pm
by msacks
Hi, please re-read my original post, I've already tried this.

Posted: Thu Apr 24, 2008 2:41 pm
by filename.txt
msacks wrote:Hi, please re-read my original post, I've already tried this.
Did you give
returnvalue(conditional)=1
or ='1'
or = "1" ?
I tried with returnvalue(conditional)=1...without quotes and it works fine.


did you check your script file..
in error I see /sbin/sh
your script should start with #!/bin/sh without spaces

Please do try to Run your script from command line.
and can you post your script ..

Posted: Thu Apr 24, 2008 2:55 pm
by ray.wurlod
Just as a test, try using a Failure trigger (this can be a separate trigger from your custom trigger, and can lead nowhere, for example into a sequencer) - it is the existence of explicit failure handling that overrides automatic error handling.