Capturing Script Output in After Job sub routine
Moderators: chulett, rschirm, roy
Capturing Script Output in After Job sub routine
Hi All,
I am calling a Unix script in the After job Sub routine of my data stage job.
Is there anyway i can capture the output returned from the script and abort the job and send a notification, in case the script did not executed correctly. ( return non zero outout)
Thanks in advance,
Punit
I am calling a Unix script in the After job Sub routine of my data stage job.
Is there anyway i can capture the output returned from the script and abort the job and send a notification, in case the script did not executed correctly. ( return non zero outout)
Thanks in advance,
Punit
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
How you calling that script from the routine?
Capturing ScreenIO returning Errorcode should give you output in variable ScreenIO and the return code in ErrorCode.
EDIT: if errorcode is not zero, the job will abort.
Capturing ScreenIO returning Errorcode should give you output in variable ScreenIO and the return code in ErrorCode.
EDIT: if errorcode is not zero, the job will abort.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.![Wink :wink:](./images/smilies/icon_wink.gif)
Genius may have its limitations, but stupidity is not thus handicapped.
![Wink :wink:](./images/smilies/icon_wink.gif)
The abort part is automatic, if you really want the notification part you'll need a different mechanism to run the script (custom routine) which checks and emails itself. Then you can decide how the routine exits, if it aborts the job or not.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
My script is running db2 statements to insert records into table. One of the insert statement did not executed correctly.ArndW wrote:If the after-job script returns an error code then the job's status is set to aborted. ...
Although i am able to see the output of the script in the Dsta Stage director log, but the job did not aborted
I am calling the script by using Afetr Job subroutine (ExecSH) option in Job properties. I just need to capture the return code of this script. Its possible to capture this code, if we use ExecActivity stage in the sequencer, but my task is to capture this output in the job and not sequencerpriyadarshikunal wrote:How you calling that script from the routine?
Capturing ScreenIO returning Errorcode should give you output in variable ScreenIO and the return code in ErrorCode.
EDIT: if errorcode is not zero, the job will abort.
Well, there's "lengthy" and then there's "proper". If this is anything like how I'd have to do it in Oracle, the script is calling the command line interface to the database - for Oracle that would be sqlplus. Once inside sqlplus, it would then run whatever DML/DDL statements are required.
Without help from you, the script will "always return a non-zero value" if it cannot launch the command line interface. Period. Once inside that, any sql failures will go unnoticed unless you specifically do something to capture and interrogate them and - when you find a problem - set the script to exit with a non-zero status after the db session ends. And it certainly doesn't take checking after every statement in the script to accomplish that.
Now, if DB2 is somehow completely different, then all my words of wisdom are for naught.![Sad :(](./images/smilies/icon_sad.gif)
Without help from you, the script will "always return a non-zero value" if it cannot launch the command line interface. Period. Once inside that, any sql failures will go unnoticed unless you specifically do something to capture and interrogate them and - when you find a problem - set the script to exit with a non-zero status after the db session ends. And it certainly doesn't take checking after every statement in the script to accomplish that.
Now, if DB2 is somehow completely different, then all my words of wisdom are for naught.
![Sad :(](./images/smilies/icon_sad.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: