Rohith Rohith - 5 months ago 31
SQL Question

How to supress the output of .sql script when placed inside bash script

Below is my simple bash script:

cd /app/oracle/client11_2/
connect <<EOF

Note: testquery.sql contains some "SELECT" queries and also i have used spool to store the content of the queries.

But, when i execute the bash script on the terminal, it produces lot of unwanted output like below:

SQL*Plus: Release
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

How to avoid this output..!? I do not want this to be printed on the output screen when i execute the bash script.


Make the here doc (<<) snippet as:

connect <<EOF >/dev/null

this sends the STDOUT of the here doc to /dev/null.

You can also do the output redirection at run time, sending the whole STDOUT of the script to /dev/null e.g.:

./ >/dev/null

again this sends the whole STDOUT of the script to /dev/null (YMMV).