0

Unexpectedly, line numbers differ when adding sqlplus after it, it doesn't make any sense. Can someone explain please?

I get 721 on line count when I comment out "sqlplus"

./general_check.sh | wc -l    

When I remove comment symbol-hash from sqlplus line I get 222 echo line count, same command

./general_check.sh | wc -l

Everything is exactly the same, why am I getting two different row counts for the same echo command?

general_check.sh

#!/bin/bash
## Declaration Section
##

export account_user=`cat user_pass`
export CUSTLIST="/tmp/special_list.lst"
export SQLDIR="../scripts"

$ORACLE_HOME/bin/sqlplus -S $account_user@db_name @${SQLDIR}/gen_special_list.sql
/bin/cat $CUSTLIST | while read CUST ORACLE_SID
do
########### 721 lines with sqlplus commented out, 222 when sqlplus below is commented in ##############
echo "|||||${CUST}|||||${ORACLE_SID}|||||"           
#### trouble maker line below ####
sqlplus -S ${CUST}/${CUST}@${ORACLE_SID} @${SQLDIR}/ctx_silly.sql>> ../reports/ctx_silly.log
done
exit
Michael Hoff
  • 6,119
  • 1
  • 14
  • 38
aymanzone
  • 135
  • 13
  • removed wc-l and got different number of echos and copied them over to count each one by one. really strange, showed to a few folks and no could make any sense of why it's happening – aymanzone Jul 24 '18 at 16:36
  • I think I found out why. sqlplus is erroring out and some affecting this script – aymanzone Jul 24 '18 at 17:41
  • 1
    Check whether sqlplus consumes stdin, like in https://stackoverflow.com/questions/13800225/shell-script-while-read-line-loop-stops-after-the-first-line – that other guy Jul 24 '18 at 20:51

0 Answers0