Page 1 of 1

Determine if a ExeCmd is invoked inside Exception Block

Posted: Thu Jul 14, 2016 8:20 pm
by eli.nawas_AUS
Hi

I have shell script that is called by ExeCmd. This ExeCmd stage can be called by either inside Exception Block or outside Exception Block. It executed fine as it really just do some logging.

What i now need is NOT to do some step while inside Exception Block.

Is there a way to determine (from shell script) if the script is invoked inside Exception Block? I want to be able to have an IF statement in the shell script to do different things depending whether it is inside Exception Block or not. Is there a Datastage system variable that get set to tell whether it is inside Exception Block or not?


Thanks.

Posted: Fri Jul 15, 2016 6:17 am
by chulett
I'm sorry but by Exception 'Block' do you mean the Exception Handler stage used in a Sequence job?

Posted: Fri Jul 15, 2016 2:17 pm
by eli.nawas_AUS
You are correct. That's what I mean: Exeception Handler stage


Thanks

Re: Determine if a ExeCmd is invoked inside Exception Block

Posted: Sun Jul 17, 2016 2:42 pm
by Palermo
There is no variable to detect an exception. You can define an environment variable (for example, status_variable=0) with DataStage Administrator client and change it before running your shell script inside 'Exception Block' with 'Execute Command' stage in 'Command' filed.

Code: Select all

status_variable=1; sh /tmp/shell_name.sh
or
status_variable=#Exception_Handler.$ErrNumber#; sh /tmp/shell_name.sh

Re: Determine if a ExeCmd is invoked inside Exception Block

Posted: Sun Jul 17, 2016 9:36 pm
by eli.nawas_AUS
Hi

That would work the way you explained. But I was thinking of not having to change existing code (ie, not adding the set variable command).

Shell script is common code called by many DS jobs. Each DS job calls the same shell script both inside and outside the Exception Handler to do some reporting. I was hoping that there's an API I can call to determine whether the code is executing inside the Exception Handler or not, so i can perform different processing depending where I am.


Thanks

Posted: Mon Jul 18, 2016 6:42 am
by chulett
There's a way to check the "interimstatus" of a job to see if it is going to abort when it wraps up, that might be helpful but AFAIK it's only available from a routine, not from the command line.

Just a thought but don't you know if it is "executing inside the Exception Handler" or not at design time, i.e. if it is in the EH branch or not? Perhaps a simple change to the script so that, rather than trying to determine the state - you pass it in as a argument instead. True when using it after an exception event, false when used elsewhere with the default being false. Seems to me that would also minimize the amount of job "code changes" you would need to make.

Posted: Tue Jul 19, 2016 12:55 pm
by eli.nawas_AUS
Hi,

Well, at this time I can only change the shell script, not the other commands inside ExeCmd. So I can't pass in a argument to the shell script to indicate whether it's in the EH as that would require change to all other DS jobs to pass in this flag. That's why i was wondering if there is an API that I can call inside the shell script.


Thanks

Posted: Tue Jul 19, 2016 1:36 pm
by chulett
As already noted, there's no such API. Hence the other suggestions.