利用uniread 解决 Linux下的SQL*Plus 命令行历史回调功能

利用uniread 解决 Linux下的SQL*Plus 命令行历史回调功能 作者: Fenng 大家知道, 在 Windows 平台 命令行中的 SQL*Plus 有命令行历史回调的功能,在SQL*Plus工具下面,可以利用键盘的 "向上向下"箭头键对命令行的进行回调.而在Linux上则没有该功能(虽然 Shell 可以做到这一点,但是 SQL*Plus 不可以). 而该功能对于CLI爱好者来说几乎是不可缺的,不知道为什么 Oracle 不把这个功能加进来.不得而知了.
一些SQL*Plus 的替代产品(如 gqlplus 以及yasql)具备command-line editing 和Command history的功能, 但是这些产品的开发进度较慢--有的甚至已经停止了更新. (参见: gqlplus http://sourceforge.net/projects/gqlplus 以及 yasql http://sourceforge.net/projects/yasql/ 等 SQL*Plus 替代工具 ). 在网络上闲逛的时候, 发现了一个在Linux下面的解决办法, 现在和大家共享. 该工具叫做uniread ( http://sourceforge.net/projects/uniread/ ) ,熟悉Linux下变成的朋友可能看到这个名字已经想起了一些东西:readline . 不错,该工具就是利用GNU的readline库来完成我们的需求的. 我们先看一下对该工具的介绍: uniread - universal readline - adds full readline support (command editing, history, etc.) to any existing interactive command-line program. Common examples are Oracle's sqlplus or jython. uniread will work on any POSIX platform with Perl. 可以看出,该工具可以对任何既有的交互命令行程序都可提供完备的readline支持. 从该站点下载源程序.目前的稳定版本是1.01. 在安装该工具之前系统必须安装好Perl, 此外还必须要三个工具包: GNU readline http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html Term::ReadLine::Gnu http://search.cpan.org/dist/Term-ReadLine-Gnu/ IO::Tty http://search.cpan.org/dist/IO-Tty/ 其中GNU readline 上面的网页在我的机器上打不开(不可访问?),如果你也是同样情况,可以到 http://www.gnu.org/directory/readline.html 这个页面下载. 下载后,首先解压缩: # tar -xzvf readline-4.3.tar.gz 进入进入到该目录中编译并安装: # ./configure # make # make install 后面两个的安装: tar -zxvf .... 进入到该目录中: # perl Makefile.pl # make # make install 都安装完了之后,进行 uniread 的安装: #tar -xzvf uniread-1.01.tar.gz #cd uniread-1.01 #./configure #make #make install 注: 以上的命令行操作所在绝对路径为了方便而省略,你的环境肯定会和我的不同,此外,建议使用普通用户编译,然后用 root 进行 make install . 都安装完了之后切换到Oracle用户下: $ uniread sqlplus /nolog 输出类似如下: [uniread] Loaded history (12 lines) //我的已经运行一次了,uniread 缓冲了12行history SQL*Plus: Release 10.1.0.2.0 - Production on Sat Mar 6 00:23:05 2004 Copyright (c) 1982, 2004, Oracle. All rights reserved. SQL>; 查看uniread的Manual: $man uniread 你可以做个sqlplus 的别名 ,uniread的使用是透明的,是不是很方便了? 不要忘了:这个工具是有通用性的,不止是 SQL*Plus 可以这样用,其他类似的命令行程序也能如此的. 参考内容: uniread的站点 http://sourceforge.net/projects/uniread GNU readline http://www.gnu.org/directory/readline.html "The Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in." 目前还算万能的Google http://www.google.com 原文出处: ;http://www.dbanotes.net/Oracle/uniread-howto.htm;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/89703/viewspace-202996/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/89703/viewspace-202996/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值