首页 > 代码库 > Linux 上安装 rlwrap

Linux 上安装 rlwrap

1.安装rlwrap的初衷;
2.安装rlwrap工具和遇到的问题;
3.使用rlwrap 工具;

1.安装rlwrap的初衷:
在Windows 下使用SQLPLUS都是可以使用上下左右方向键前后左右翻转移动,每句命令也是可以往前或往后修改,但Linux 下却不行,一直要使用SQLPLUS,这样做有些难受,网上查询了下,可以使用rlwrap 解决这个问题,安装中遇到些问题记录如下,方便以后查阅;
 
2.安装rlwrap工具和遇到的问题:
2.1到rlwrap官网(http://utopia.knoware.nl/~hlub/uck/rlwrap)下载rlwrap工具,目前版本是0.4.1;
2.2 解压rlwrap工具包:

[root@wusuyuan ~]#tar -zxvf rlwrap-0.41.tar.gz 
 
[root@wusuyuan ~]#cd rlwrap-0.41
 
[root@wusuyuan rlwrap-0.41]# ./configure 
<style type="text/css">.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }</style>如果最后提示 You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build this program!
则还需要安装:readline
[root@wusuyuan rlwrap-0.41]# yum -y install readline*
<style type="text/css">.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }</style>关联包:
ncurses-devel-5.7-3.20090208.el6.x86_64
readline-devel-6.0-4.el6.x86_64
readline-static-6.0-4.el6.x86_64
readline-static-6.0-4.el6.x86_64
readline-devel-6.0-4.el6.x86_64
ncurses-devel-5.7-3.20090208.el6.x86_64 
那如果这些包安装失败,可以到官网上找这些包下载独立安装,安装无误后,在一次尝试:
[root@wusuyuan rlwrap-0.41]# ./configure 
<style type="text/css">.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }</style>没有任何错误后 make
[root@wusuyuan rlwrap-0.41]# make
[root@wusuyuan rlwrap-0.41]# make install
<style type="text/css">.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }</style>至此rlwrap工具安装成功,键入rlwrap 后能看到相应提示;

3.使用rlwrap 工具:
输入 rlwrap 后跟 sqlplus,sqlplus后面的参数和平常的一样,不一样的地方就是多了前缀,多了个伴;

[sywu@wusuyuan rlwrap-0.41]$ rlwrap sqlplus /
 
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jun 13 22:32:30 2014
 
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
 
 
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
 
OPS$SYWU@sydb>
 
<style type="text/css">.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }</style>

从此方向键的约束彻底解放,不用再担心输错和找不到前几句命令了,好好研究吧!!!