Page 1 of 1

rsh return code

Posted: Wed Jan 16, 2008 5:20 am
by agathaeleanor
Hi all.

May i know how to have the rsh command's return code correctly?
I have my script as

`rsh 10.1.65.196 -l ciopr01 ksh "/recovery/dmprod/prepaid_loading/scripts/DM_Sqlldr_enh.ksh ${TARGET_TABLE_NAME} ${JOB_NAME} ${DATA_SOURCE_NAME} ${USER_ID} ${PASSWORD}"; echo$?`

Even if my DM_Sqlldr_enh.ksh doing sqlloading, and the sqlload return code is 2, but by default it returns me 0.

Appreciate if anyone would help out or pointing to useful resources.

Posted: Wed Jan 16, 2008 7:49 am
by chulett
Your script is working fine, hence the 0. You need to add extra logic to detect the sqlldr failure and propogate that, typically by grepping the log for ORA errors and checking to see if a "bad" file was created.

Posted: Thu Jan 17, 2008 6:53 pm
by agathaeleanor
It is working now. Instead of grepping the bad file, I redirect the return code of sqlloading to a file and grep the result there.

Thank you, chulett.

Posted: Thu Jan 17, 2008 7:20 pm
by chulett
Good. :D

For the record, I didn't say to grep the bad file, merely checking for its existence is enough. I have been known to grep the actual 'log' file for specific errors as well as check the return code explicitly.