【转载】sqlplus中上下方向键回调历史命令--rlwrap安装

rlwrap 可用来支持Oracle下sqlplus历史命令的回调功能,提高效率。

1、下载

从http://utopia.knoware.nl/~hlub/uck/rlwrap/下载rlwrap-0.37.tar.gz,然后上传到相应目录

0.37版本在redhat6上安装的时候会报没有依赖包,其实是高版本的依赖包软件找不到,不想摆弄了。我在网上其他地方搜了一个 rlwrap-0.42,可以在redhat6上直接装。

2.安装

2.1主要步骤是:

./configure

make

make install

2.2下面包含了具体的安装调试信息

[[email protected] soft]# gzip -d rlwrap-0.37.tar.gz

[[email protected] soft]# tar -xvf rlwrap-0.37.tar

[[email protected] rlwrap-0.37]# ./configure

checking build system type... i686-pc-Linux-gnu

checking host system type... i686-pc-linux-gnu

checking for a BSD-compatible install... /usr/bin/install -c

checking whether build environment is sane... yes

checking for a thread-safe mkdir -p... /bin/mkdir -p

checking for gawk... gawk

checking whether make sets $(MAKE)... yes

checking whether make sets $(MAKE)... (cached) yes

checking whether build environment is sane... yes

checking for style of include used by make... GNU

checking for gcc... gcc

checking for C compiler default output file name... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... no

checking for suffix of executables...

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ISO C89... none needed

checking dependency style of gcc... gcc3

checking how to run the C preprocessor... gcc -E

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking minix/config.h usability... no

checking minix/config.h presence... no

checking for minix/config.h... no

checking whether it is safe to define __EXTENSIONS__... yes

checking for gcc... (cached) gcc

checking whether we are using the GNU C compiler... (cached) yes

checking whether gcc accepts -g... (cached) yes

checking for gcc option to accept ISO C89... (cached) none needed

checking dependency style of gcc... (cached) gcc3

checking how to run the C preprocessor... gcc -E

checking for perl... /usr/bin/perl

checking for strip... strip

checking for ANSI C header files... (cached) yes

checking for sys/wait.h that is POSIX.1 compatible... yes

checking errno.h usability... yes

checking errno.h presence... yes

checking for errno.h... yes

checking fcntl.h usability... yes

checking fcntl.h presence... yes

checking for fcntl.h... yes

checking libutil.h usability... no

checking libutil.h presence... no

checking for libutil.h... no

checking for stdlib.h... (cached) yes

checking for string.h... (cached) yes

checking sched.h usability... yes

checking sched.h presence... yes

checking for sched.h... yes

checking sys/ioctl.h usability... yes

checking sys/ioctl.h presence... yes

checking for sys/ioctl.h... yes

checking for sys/wait.h... (cached) yes

checking sys/resource.h usability... yes

checking sys/resource.h presence... yes

checking for sys/resource.h... yes

checking stddef.h usability... yes

checking stddef.h presence... yes

checking for stddef.h... yes

checking termios.h usability... yes

checking termios.h presence... yes

checking for termios.h... yes

checking for unistd.h... (cached) yes

checking for stdint.h... (cached) yes

checking time.h usability... yes

checking time.h presence... yes

checking for time.h... yes

checking getopt.h usability... yes

checking getopt.h presence... yes

checking for getopt.h... yes

checking regex.h usability... yes

checking regex.h presence... yes

checking for regex.h... yes

checking curses.h usability... no

checking curses.h presence... no

checking for curses.h... no

checking termcap.h usability... no

checking termcap.h presence... no

checking for termcap.h... no

checking for term.h... no

checking for ncurses/term.h... no

checking argument type of tputs putc function... char

checking whether your getopt() correctly understands double colons in option string... yes

checking for an ANSI C-conforming const... yes

checking for pid_t... yes

checking whether time.h and sys/time.h may both be included... yes

checking whether gcc needs -traditional... no

checking return type of signal handlers... void

checking for getopt_long... yes

checking for getopt_long... (cached) yes

checking for isastream... yes

checking for mkstemp... yes

checking for pselect... yes

checking for putenv... yes

checking for readlink... yes

checking for sched_yield... yes

checking for setenv... yes

checking for setitimer... yes

checking for setsid... yes

checking for setrlimit... yes

checking for sigaction... yes

checking for snprintf... yes

checking for strlcpy... no

checking for strlcat... no

checking for strnlen... yes

checking for system... yes

checking for openpty in -lutil... yes

checking for openpty... yes

checking for getpty... no

checking for grantpt... yes

checking for unlockpt... yes

checking for getpt... yes

checking for pty/tty type... checking pty.h usability... yes

checking pty.h presence... yes

checking for pty.h... yes

OPENPTY

configure: checking for pty ranges...

checking for tgetent... no

checking for tgetent in -lcurses... yes

checking for readline in -lreadline... no

configure: error:

You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build

this program!

[[email protected] rlwrap-0.37]# make

make: *** No targets specified and no makefile found.  Stop.

出现上面错误是因为缺少三个安装包:

libtermcap-devel-2.0.8-39.i386.rpm

readline-4.3-13.i386.rpm

readline-devel-4.3-13.i386.rpm

以上安装包在安装光盘中可以找到。

[[email protected] rlwrap-0.37]# rpm -qa|grep read

readline-4.3-13

安装以下三个包:

[[email protected] rpms]# rpm -Uvh readline*

[[email protected] rpms]# rpm -ivh libtermcap-devel-2.0.8-39.i386.rpm

检查是否安装成功:

[[email protected] rpms]# rpm -qa|grep readline

readline-4.3-13

readline-devel-4.3-13

[[email protected] rpms]# rpm -qa|grep libter

libtermcap-2.0.8-39

libtermcap-devel-2.0.8-39

[[email protected] rpms]#

重新安装:

[[email protected] rlwrap-0.37]# ./configure

[[email protected] rlwrap-0.37]# make

make  all-recursive

make[1]: Entering directory `/soft/rlwrap-0.37‘

Making all in doc

make[2]: Entering directory `/soft/rlwrap-0.37/doc‘

sed -e ‘s#@[email protected]#/usr/local/share#‘  rlwrap.man > rlwrap.1

make[2]: Leaving directory `/soft/rlwrap-0.37/doc‘

Making all in src

make[2]: Entering directory `/soft/rlwrap-0.37/src‘

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c

mv -f .deps/main.Tpo .deps/main.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT signals.o -MD -MP -MF .deps/signals.Tpo -c -o signals.o signals.c

mv -f .deps/signals.Tpo .deps/signals.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT readline.o -MD -MP -MF .deps/readline.Tpo -c -o readline.o readline.c

mv -f .deps/readline.Tpo .deps/readline.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT pty.o -MD -MP -MF .deps/pty.Tpo -c -o pty.o pty.c

mv -f .deps/pty.Tpo .deps/pty.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT completion.o -MD -MP -MF .deps/completion.Tpo -c -o completion.o completion.c

mv -f .deps/completion.Tpo .deps/completion.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT term.o -MD -MP -MF .deps/term.Tpo -c -o term.o term.c

mv -f .deps/term.Tpo .deps/term.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT ptytty.o -MD -MP -MF .deps/ptytty.Tpo -c -o ptytty.o ptytty.c

mv -f .deps/ptytty.Tpo .deps/ptytty.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT utils.o -MD -MP -MF .deps/utils.Tpo -c -o utils.o utils.c

mv -f .deps/utils.Tpo .deps/utils.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT string_utils.o -MD -MP -MF .deps/string_utils.Tpo -c -o string_utils.o string_utils.c

string_utils.c: In function `colourless_strlen‘:

string_utils.c:626: warning: assignment discards qualifiers from pointer target type

mv -f .deps/string_utils.Tpo .deps/string_utils.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT malloc_debug.o -MD -MP -MF .deps/malloc_debug.Tpo -c -o malloc_debug.o malloc_debug.c

mv -f .deps/malloc_debug.Tpo .deps/malloc_debug.Po

gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/share\"  -g -O2 -MT filter.o -MD -MP -MF .deps/filter.Tpo -c -o filter.o filter.c

mv -f .deps/filter.Tpo .deps/filter.Po

gcc -DDATADIR=\"/usr/local/share\"  -g -O2   -o rlwrap main.o signals.o readline.o pty.o completion.o term.o ptytty.o utils.o string_utils.o malloc_debug.o filter.o  -lutil  -lreadline -lcurses

make[2]: Leaving directory `/soft/rlwrap-0.37/src‘

Making all in filters

make[2]: Entering directory `/soft/rlwrap-0.37/filters‘

make[2]: Nothing to be done for `all‘.

make[2]: Leaving directory `/soft/rlwrap-0.37/filters‘

make[2]: Entering directory `/soft/rlwrap-0.37‘

make[2]: Nothing to be done for `all-am‘.

make[2]: Leaving directory `/soft/rlwrap-0.37‘

make[1]: Leaving directory `/soft/rlwrap-0.37‘

[[email protected] rlwrap-0.37]#

[[email protected] rlwrap-0.37]# make install

Making install in doc

make[1]: Entering directory `/soft/rlwrap-0.37/doc‘

make[2]: Entering directory `/soft/rlwrap-0.37/doc‘

make[2]: Nothing to be done for `install-exec-am‘.

test -z "/usr/local/share/man/man1" || /bin/mkdir -p "/usr/local/share/man/man1"

/usr/bin/install -c -m 644 rlwrap.1 ‘/usr/local/share/man/man1‘

make[2]: Leaving directory `/soft/rlwrap-0.37/doc‘

make[1]: Leaving directory `/soft/rlwrap-0.37/doc‘

Making install in src

make[1]: Entering directory `/soft/rlwrap-0.37/src‘

make[2]: Entering directory `/soft/rlwrap-0.37/src‘

test -z "/usr/local/bin" || /bin/mkdir -p "/usr/local/bin"

/usr/bin/install -c rlwrap ‘/usr/local/bin‘

make[2]: Nothing to be done for `install-data-am‘.

make[2]: Leaving directory `/soft/rlwrap-0.37/src‘

make[1]: Leaving directory `/soft/rlwrap-0.37/src‘

Making install in filters

make[1]: Entering directory `/soft/rlwrap-0.37/filters‘

make[2]: Entering directory `/soft/rlwrap-0.37/filters‘

make[2]: Nothing to be done for `install-exec-am‘.

test -z "/usr/local/share/man/man3" || /bin/mkdir -p "/usr/local/share/man/man3"

/usr/bin/install -c -m 644 RlwrapFilter.3pm ‘/usr/local/share/man/man3‘

make[2]: Leaving directory `/soft/rlwrap-0.37/filters‘

make[1]: Leaving directory `/soft/rlwrap-0.37/filters‘

make[1]: Entering directory `/soft/rlwrap-0.37‘

make[2]: Entering directory `/soft/rlwrap-0.37‘

make[2]: Nothing to be done for `install-exec-am‘.

test -z "/usr/local/share/rlwrap" || /bin/mkdir -p "/usr/local/share/rlwrap"

/bin/mkdir -p ‘/usr/local/share/rlwrap/filters‘

/usr/bin/install -c -m 644  filters/README filters/RlwrapFilter.pm filters/RlwrapFilter.3pm filters/count_in_prompt filters/pipeto filters/logger filters/null filters/unbackspace filters/pipeline filters/ftp_filter filters/history_format filters/simple_macro filters/template filters/scrub_prompt filters/paint_prompt filters/censor_passwords filters/listing ‘/usr/local/share/rlwrap/filters‘

/bin/mkdir -p ‘/usr/local/share/rlwrap/completions‘

/usr/bin/install -c -m 644  completions/testclient completions/coqtop ‘/usr/local/share/rlwrap/completions‘

make  install-data-hook

make[3]: Entering directory `/soft/rlwrap-0.37‘

chmod a+x /usr/local/share/rlwrap/filters/*

make[3]: Leaving directory `/soft/rlwrap-0.37‘

make[2]: Leaving directory `/soft/rlwrap-0.37‘

make[1]: Leaving directory `/soft/rlwrap-0.37‘

[[email protected] rlwrap-0.37]#

3、验证安装结果

[[email protected] rlwrap-0.37]#su – oracle

[[email protected] ~]$ rlwrap

4、安装报错

rlwrap: error while loadingshared libraries: libreadline.so.5: cannot open shared object file: No suchfile or directory

解决办法:

在oracle下的.bash_profile中$PATH路径中增加/usr/local/bin路径

PATH=/usr/local/bin:$PATH;export PATH

5、编辑oracle用户下的.bash_profile

增加

alias sqlplus=’rlwrap sqlplus’

alias rman=’rlwrap rman’

6.其他

临时解决办法

避免 backspace 出现奇怪的符号,可以在xshell中

文件-->打开-->属性-->键盘

delete键序列配置为:ASCII 127

backspace键序列配置为:backspace

在环境变量中增加

stty erase ‘^H‘

时间: 2024-08-02 06:59:18

【转载】sqlplus中上下方向键回调历史命令--rlwrap安装的相关文章

【转载】Oracle sqlplus中最简单的一些命令,设置显示的格式

登录数据库: 方式(1)当我们刚安装Oracle数据库时,登录账户时可以使用win+r 输入sqlplus,进入sqlplus命令窗口,然后输入用户名和密码,这里输入密码时不会有回显 方式(2)使用win+r 输入cmd,进入dos命令窗口,然后输入用户名和密码,这里输入密码时不会有回显 或者使用直接输入命令sqlplus 用户名/密码即可 登录账户后,我们可以使用 SHOW USER 来显示我们当前的用户名 如果想要切换用户: 使用CONN SYSTEM/ADMIN 格式为CONN 用户名/密

[转载]linux中各种压缩包的解压缩命令

表1 Linux常用的压缩及解压缩命令说明 常用命令 简要中文说明 程序所在目录 gzip 压缩成文件名为 .gz 的压缩文件(也可用 –d 选项变成解压) /bin gunzip 将 .gz 压缩文件解压(可用 gzip 加 –d 参数代替) /bin tar 打包为 .tar 的打包文件或解开(也可配合 –z 选项呼叫 gzip进行 .gz 文件的压缩或解压) /bin compress 压缩成文件名为 .Z 的压缩文件(也可用 –d 选项变成解压) /usr/bin uncompress

(转载)Bash 中的特殊字符大全

转自:https://linux.cn/article-5657-1.html Linux下无论如何都是要用到shell命令的,在Shell的实际使用中,有编程经验的很容易上手,但稍微有难度的是shell里面的那些个符 号,各种特殊的符号在我们编写Shell脚本的时候如果能够用的好,往往能给我们起到事半功倍的效果,为此,特地将Shell里面的一些符号说明罗列成对 照表的形式,以便快速的查找.看看你知道下表中的哪些Shell符号呢? Shell符号及各种解释对照表: Shell符号 使用方法及说明

历史命令history

历史命令在用户注销之后会保存在用户家目录下的-/.bash_history中 history #查看系统中实时缓存的历史命令,与.bash_history中的内容并不完全相同 history -c #清空历史命令 history -w #把缓存中的历史命令写入历史命令保存文件.bash_history中 历史命令的存储容量可在/etc/profile中通过添加 HISTSIZE=1000 来改变. 历史命令的调用: 使用上.下箭头或ctrl+p.ctrl+n 使用 !n 执行第n条历史命令 使用

历史命令~/.bash_history

历史命令大小:/etc/profile中字段HISTSIZE=1000 历史命令保存文件:~/.bash_history history -c 清空历史命令 history -w 把历史命令写入~/.bash_history !n执行第n条历史命令 !!执行上一条历史命令 !字串 重复执行最后一条以该字串开头的历史命令 设置别名:alias 别名='原命令' 命令执行顺序:1.绝对路径或相对路径:2.别名:3.bash内部命令:4.$PATH环境变量定义的目录查找到的第一个命令

历史命令

如何查看历史命令? history [-c -w] -c 清空历史命令 -w 强制保存缓存中历史命令 选项都不选,查看历史命令 如何更改历史命令保存条数? vi /etc/profile 更改HISTSIZE=1000后面数字,占用空间几kb 历史命令对服务器安全? 历史命令保存在家目录下 .bash_history 中,以隐藏文件出现 不需要清空历史命令,新的管理员可以通过历史命令,查看老管理员对服务器进行了哪些操作,还有一旦发现服务器历史命令被手动清空,说明服务器不安全,需要进行安全升级 如

SqlPlus中退格键和方向键的设置

在刚装好的Oracle中,我们使用SqlPlus会发现非常的蹩脚,不仅退格键不好用,方向键也不行调出history,下面有几种解决方法. 1.可以使用ctrl+Backspace键强制输出输入的错误,也可以export stty erase ^h,当然这只是临时的方法,想一劳永逸请看下面. 2.在oracle用户目录下编辑bash_profile文件 [[email protected] ~]$ vi .bash_profile 添加以下代码 stty erase ^h 保存退出 使修改生效 [

使用rlwrap实现sqlplus上下键翻阅输过的oracle历史命令

初学Oracle的同学可能在Linux 下使用SecureCRT来连接服务器,在使用sqlplus时像调用之前输入过的命令重新执行,没法实现???? 同样的问题肯定前辈们一定也遇到过,所以就Google了一下,找到了rlwrap这个工具,下面我们来一起看下吧: rlwrap 下载地址:http://utopia.knoware.nl/~hlub/uck/rlwrap/#rlwrap 一.安装readline包 在系统的光盘中我们很容易找到符合自己版本的包 #rpm -qa| grep readl

sqlite3 shell方向键、浏览历史命令不能用的问题

在sqlite3 shell下,按上下方向键可以浏览历史命令,按左右方向键则可以将光标移动到命令中任意字符位置,从而可以修改错误的语句或误敲的字符.所以方向键是sqlite3 shell下最常用的功能. 在debian(包含ubuntu)下,sqlite3 shell方向键默认是不工作的. ?这个问题是有意为之的,原因是:命令行编辑特性是有外部依赖的,sqlite3二进制包的维护者不对可用的外部库作假定,默认不去引用这些外部库,否则,二进制包可能是不可用的. 命令行编辑特性依赖的外部库是read