0

Below is my simple bash script:

#!/bin/bash
cd /app/oracle/client11_2/
connect <<EOF
@/app/oracle/client11_2/testquery.sql
exit;
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 11.2.0.3.0
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 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.

2 Answers 2

2

You can suppress the SQL*Plus header messages by using the -s flag

sqlplus -s

That said, your snippet shows a connect but not the sqlplus invocation itself. Not sure where that is being hidden.

Sign up to request clarification or add additional context in comments.

Comments

0

Make the here doc (<<) snippet as:

connect <<EOF >/dev/null
@/app/oracle/client11_2/testquery.sql
exit;
EOF

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.:

./script.sh >/dev/null

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.