1

this is my scash script

 query="select * from blabla;"    
    sqlplus64 -S /nolog <<ENDOFSQL>>errorLog.txt 
               CONNECT username/pwd@domainName:1521/serviceName
               whenever sqlerror exit sql.sqlcode;
               $query 
               exit;
    ENDOFSQL
               ERRORCODE=$?

                   if [ $ERRORCODE -eq 0 ];
                      then
                          echo  "$query" >> "sqlTemp.SQL"
                          echo  -e  "$query \n this query is successful" 

                      else
                          echo -e "$query \nthis query has  error- check the log file for detail" 

                   fi

My requirement is to collect only the error, instead I am getting all error and successful data.

I have tried

1.sqlplus64 -S /nolog <<ENDOFSQL2>>errorLog.txt 
2.sqlplus64 -S /nolog <<ENDOFSQL 2>&1>errorLog.txt 

I can't use a pipe as errorcode will not receive the desired error code.

  • 2
    Have you tried sqlplus64 -S /nolog <<ENDOFSQL 2>>errorLog.txt? With a space before the 2? – terdon Jun 13 '17 at 8:11
1

use the bash redirection

Script.sh 2> Error.log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.