|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
While loop variable
Code:
while read -r tabname rem
do
select count(*) from $tabname" > /dev/null
RC=$?
if [[ $RC != 0 ]]
then
echo "error on $tabname" >> error.out
fi
donewell in above code i need the echo "error on $tabname" to come in separate o/p file which show the table name whc doesn't pass RC =0. but not getting any o/p in erro.out.Any thing that need to check.?? |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Doesn't your shell show any error on this line when executing the script? Code:
select count(*) from $tabname" > /dev/null |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
hi zaxxon, actually the code i shown you is not complete ..it has db connection.That part is runnign fine Rc is validating but the Problem is m not getting error.out in separate file. Code:
echo "error on $tabname" >> error.out |
|
#4
|
||||
|
||||
|
Ok
![]() The problem will most probably be, that the DB client you are using, will just show a RC of 0 all the time, no matter if the SQL statement issued was successful or not. You got the same issue, if you do something with a ftp client or any other client, that works fine in terms of itself, no matter what errors you get "inside" the client. There is usually issued a 0 back to the shell as the client says "Hey man, I am fine, not my fault the commands you issued didn't work because of <insertsomethingthatwentwrong>". Can simply check this if you add a echo $RC after defining $RC while issuing an intentionally failing SQL statement in the line above. I am not sure if there is any kind of option for your DB client to pass any other RC through to the shell. Could check it's documentation maybe; or grep for a pattern that shows the success/fail of the operation. Update: For DB2 I found that the client returns appropriate RCs: http://publib.boulder.ibm.com/infoce...e/r0010411.htm Just as an example that some clients do that. Last edited by zaxxon; 02-15-2013 at 08:56 AM.. Reason: added info |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Array Variable being Assigned Values in Loop, But Gone when Loop Completes??? | mrm5102 | Shell Programming and Scripting | 5 | 10-19-2012 10:00 AM |
| Loop and variable not exactly variable: what's wrong | bobylapointe | UNIX for Dummies Questions & Answers | 4 | 06-30-2012 07:40 AM |
| printing variable with variable suffix through loop | oly_r | Shell Programming and Scripting | 4 | 06-26-2012 02:00 PM |
| [SHELL: /bin/sh] For loop using variable variable names | Vryali | Shell Programming and Scripting | 2 | 06-06-2012 10:47 AM |
| how to get the variable in while loop outside of it? | munish259272 | Shell Programming and Scripting | 3 | 11-07-2011 12:31 AM |
|
|