日期:2014-05-16  浏览次数:20692 次

linux下sqlplus调出历史命令--rlwrap介绍
转自:http://space.itpub.net/15142212/viewspace-558108

1:安装
rlwrap-0.28.tar.gz下载地址:http://utopia.knoware.nl/~hlub/uck/rlwrap/

(现是已升级到0.30了)
1):解压缩安装文件
[oracle@Channel-MQ3 ~]$gunzip rlwrap-0.28.tar.gz
[oracle@Channel-MQ3 ~]$tar xvf rlwrap-0.28.tar
2):切换到root用户,执行下面的命令
[root@Channel-MQ3 ~]# cd /home/oracle/rlwrap-0.28
[root@Channel-MQ3 rlwrap-0.28]# ls
aclocal.m4 completions configure INSTALL README TODO
AUTHORS config.h configure.ac Makefile src tools
bash30-005.patch config.h.in COPYING Makefile.am stamp-h1
BUGS config.log distribution Makefile.in test
ChangeLog config.status doc NEWS test.log
[root@Channel-MQ3 rlwrap-0.28]#./configure
[root@Channel-MQ3 rlwrap-0.28]#make
[root@Channel-MQ3 rlwrap-0.28]#make install

2:使用
$ rlwrap [-options] <command> <args>
[oracle@Channel-MQ3 ~]$ which rlwrap
/usr/local/bin/rlwrap
[oracle@Channel-MQ3 ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 18 10:31:11 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from v$sga;

NAME VALUE
-------------------- ----------
Fixed Size 1219856
Variable Size 121635568
Database Buffers 310378496
Redo Buffers 7168000

-- 使用向上键调回最后执行的命令,按[Enter]重新执行或修改后按[Enter]执行
SQL> select * from v$sga;

NAME VALUE
-------------------- ----------
Fixed Size 1219856
Variable Size 121635568
Database Buffers 310378496
Redo Buffers 7168000

另外rlwrap还有很多选项可以设置
eg:
?l, ??logfile file
Append command’s output (including echo’ed user input) to file (creating file when it doesn’t exist).

测试如下
[oracle@Channel-MQ3 ~]$ rlwrap -l benbotest.log sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 18 10:34:50 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from v$version;

BANNER
----------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@Channel-MQ3 ~]$ cat benbotest.log


[rlwrap] Wed Jul 18 10:34:50 2007


SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jul 18 10:34:50 2007

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select * from v$version;

BANNER
----------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@Channel-MQ3 ~]$

其它选择轻参考manpage.

相关资源:
rlwrap-0.28.tar.gz (150 k)http://utopia.knoware.nl/~hlub/uck/rlwrap/
The