Search code examples
oracle-databaseshellsqlplus

Sqlplus in silent mode is not silent


I'm using sqlplus in shell script and it works(sqlplus without silent mode) but I can see the output in the terminal. I tried running it in silent mode with different combinations but it didn't work -

sqlplus -s "$DBUSER/$DBPWD@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=$DBHOST)(Port=$DBPORT))(CONNECT_DATA=(SID=$DBSID)))"  @$SCRHOME/getCsv$sqlFile.sql

<Btw the -s is in yellow and not black, like the echo command in a shell script>

It works but I can see the output on console. I also tried:

sqlplus \-s "....
sqlplus \-s \ "...
sqplus -S
sqlplus -s \ << EOF "...

I tried removing the double quotes, but then in that case even the sqlplus command doesn't work. I'm using this command in a shell script.


Solution

  • The correct format is:

    sqlplus -S LOGIN_INFO @SCRIPT_TO_RUN
    

    The "silent" mode doesn't prevent terminal output. All it does is:

    -S             Sets silent mode which suppresses the display of
                   the SQL*Plus banner, prompts, and echoing of
                   commands.
    

    If you want to suppress all terminal output, then you'll need to do something like:
    sqlplus ... > /dev/null 2>&1