[英]How to supress the output of .sql script when placed inside bash script
Below is my simple bash script: 以下是我简单的bash脚本:
#!/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. 注意:testquery.sql包含一些“ SELECT”查询,并且我也使用假脱机来存储查询的内容。
But, when i execute the bash script on the terminal, it produces lot of unwanted output like below: 但是,当我在终端上执行bash脚本时,它会产生很多不需要的输出,如下所示:
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.
我不希望在执行bash脚本时将其打印在输出屏幕上。
You can suppress the SQL*Plus header messages by using the -s flag 您可以使用-s标志取消显示SQL * Plus标头消息
sqlplus -s
That said, your snippet shows a connect but not the sqlplus invocation itself. 就是说,您的代码片段显示了一个连接,但未显示sqlplus调用本身。 Not sure where that is being hidden.
不知道在哪里被隐藏。
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
. 这会将here doc的STDOUT发送到
/dev/null
。
You can also do the output redirection at run time, sending the whole STDOUT of the script to /dev/null
eg: 您还可以在运行时进行输出重定向,将脚本的整个STDOUT发送到
/dev/null
例如:
./script.sh >/dev/null
again this sends the whole STDOUT of the script to /dev/null
(YMMV). 再次,这会将脚本的整个STDOUT发送到
/dev/null
(YMMV)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.