Locations of visitors to this page

Tuesday, December 2, 2008

how to suppress “Connected.” message - 如何禁止SQLPLUS报的"Connected."信息

---------- Forwarded message ----------
From: wen xie <xiewenxiewen at googlemail.com>
Date: 2008/12/2
Subject: Fwd: how to suppress "Connected." message
To: xiewenxiewen at googlemail.com

---------- Forwarded message ----------
From: XIE WEN-MFK346 <wenxie at motorola.com>
Date: 2008/12/2
Subject: how to suppress "Connected." message
To: wen xie <xiewenxiewen at googlemail.com>


sqlplus用connect连接数据库后会显示"Connected."提示信息
sqlplus
/nolog <<EOF
conn / as sysdba
exit
EOF
[oracle@DEV-DB-1 ~]$ sqlplus /nolog <<EOF
> conn / as sysdba
> exit
> EOF
SQL*Plus: Release 9.2.0.6.0 - Production on Tue Dec 2 03:27:13 2008
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
SQL>
Connected.
SQL>
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.6.0 - Production


即使在安静模式下也会显示出来
sqlplus -s /nolog <<EOF
conn / as sysdba
exit
EOF
[oracle@DEV-DB-1 ~]$ sqlplus -s /nolog <<EOF
> conn / as sysdba
> exit
> EOF
Connected.



1.
直接在sqlplus命令后连接数据库
sqlplus -s "/ as sysdba" <<'EOF'
select 1 from
dual;
exit
EOF
[oracle@DEV-DB-1 ~]$ sqlplus -s "/ as sysdba" <<'EOF'
> select 1 from dual;
> exit
> EOF
1
----------
1
不过这样写不安全


2.
用sed脚本去掉"Connected."
sqlplus -s /nolog <<'EOF' |sed '/^Connected./d'
conn / as sysdba
select 1 from dual;
exit
EOF
[oracle@DEV-DB-1 ~]$ sqlplus -s /nolog <<'EOF' |sed '/^Connected./d'
> conn / as sysdba
> select 1 from dual;
> exit
> EOF
1
----------
1


3.
10.2版本以后的sqlplus在安静模式下不显示"Connected.", 修复了这个缺陷
sqlplus -s /nolog <<EOF
conn / as sysdba
select 1 from dual;
exit
EOF
sqlplus -v
[oracle@DEV-DB-1 ~]$ sqlplus -s /nolog <<EOF
> conn / as sysdba
> select 1 from dual;
> exit
> EOF
1
----------
1

[oracle@DEV-DB-1 ~]$ sqlplus -v
SQL*Plus: Release 10.2.0.4.0 - Production



外部链接:
How
to Stop 'Connected' Message when Running SQLPlus in Silent Mode?

sqlplus:
I want to avoid the 'Connected.' string







Xie Wen (谢文)
Network & Operations, Multimedia Applications & Services (MDB)
MOTOROLA Inc.
NO.104 mail box, 8th floor, Motorola Tower,
No. 1 Wang Jing East Road, Chao Yang District,
Beijing 100102 P. R. China
e-mail wenxie at motorola.com




-fin-

No comments:

Website Analytics

Followers