rlwrap是一个在Unix-like系统中广泛使用的工具,它允许用户通过命令行界面(CLI)与程序交互时,使用如退格键、方向键等编辑功能,以及命令历史记录等特性。这对于使用如Oracle sqlplus等不支持这些功能的程序时特别有用。以下是rlwrap的安装和配置步骤:
一、安装rlwrap
1. 准备工作
- 下载安装包:首先,需要下载rlwrap的安装包。通常,这个安装包是一个压缩文件,如
rlwrap-x.xx.tar.gz
(其中x.xx
是版本号)。可以从rlwrap的官方网站或其他可靠的软件源下载。 - 安装依赖:rlwrap依赖于一些库文件,如
readline
和readline-devel
(或类似名称的库,具体取决于操作系统)。在安装rlwrap之前,需要确保这些依赖库已经安装。可以使用包管理器(如yum、apt等)来安装这些依赖。
-- centos7.x/redhat7.x 操作系统
[root@racdb1 ~]# rpm -ivh ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm --force --nodeps
warning: ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:ncurses-devel-5.9-14.20130511.el7################################# [100%]
[root@racdb1 ~]# rpm -ivh readline-devel-6.0-4.el6.x86_64.rpm --force --nodeps
warning: readline-devel-6.0-4.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:readline-devel-6.0-4.el6 ################################# [100%]
-- Centos8.X/redhat8.X 操作系统(挂载好光驱,设置好dnf源)
[root@racdb1 rlwrap-0.46.1]# dnf install ncurses-devel
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 1 day, 3:26:29 ago on Mon 26 Aug 2024 11:03:02 AM CST.
Package ncurses-devel-5.9-14.20130511.el7_4.x86_64 is already installed.
Dependencies resolved.
========================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================
Upgrading:
ncurses-devel x86_64 6.1-7.20180224.el8 EL8-2 528 k
Installing dependencies:
ncurses-c++-libs x86_64 6.1-7.20180224.el8 EL8-2 58 k
Transaction Summary
========================================================================================================================
Install 1 Package
Upgrade 1 Package
Total size: 586 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : ncurses-c++-libs-6.1-7.20180224.el8.x86_64 1/3
Upgrading : ncurses-devel-6.1-7.20180224.el8.x86_64 2/3
Cleanup : ncurses-devel-5.9-14.20130511.el7_4.x86_64 3/3
Running scriptlet: ncurses-devel-5.9-14.20130511.el7_4.x86_64 3/3
Verifying : ncurses-c++-libs-6.1-7.20180224.el8.x86_64 1/3
Verifying : ncurses-devel-6.1-7.20180224.el8.x86_64 2/3
Verifying : ncurses-devel-5.9-14.20130511.el7_4.x86_64 3/3
Installed products updated.
Upgraded:
ncurses-devel-6.1-7.20180224.el8.x86_64
Installed:
ncurses-c++-libs-6.1-7.20180224.el8.x86_64
Complete!
[root@racdb1 ~]# dnf -y install readline readline-devel
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 1 day, 3:02:52 ago on Mon 26 Aug 2024 11:03:02 AM CST.
Package readline-7.0-10.el8.x86_64 is already installed.
Package readline-devel-6.0-4.el6.x86_64 is already installed.
Dependencies resolved.
========================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================
Upgrading:
readline-devel x86_64 7.0-10.el8 EL8-2 204 k
Transaction Summary
========================================================================================================================
Upgrade 1 Package
Total size: 204 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Upgrading : readline-devel-7.0-10.el8.x86_64 1/2
Running scriptlet: readline-devel-7.0-10.el8.x86_64 1/2
Running scriptlet: readline-devel-6.0-4.el6.x86_64 2/2
Cleanup : readline-devel-6.0-4.el6.x86_64 2/2
Running scriptlet: readline-devel-6.0-4.el6.x86_64 2/2
Verifying : readline-devel-7.0-10.el8.x86_64 1/2
Verifying : readline-devel-6.0-4.el6.x86_64 2/2
Installed products updated.
Upgraded:
readline-devel-7.0-10.el8.x86_64
Complete!
2. 安装过程
-
解压安装包:将下载的rlwrap安装包解压到某个目录,例如
/usr/local/src
。 -
编译安装:
- 进入解压后的目录。
- 运行
./configure
脚本来配置安装选项(这一步是可选的,但通常建议执行以确保所有依赖都被正确识别)。 - 运行
make
命令来编译rlwrap。 - 运行
make install
命令来安装rlwrap。
示例命令如下:
tar -zxvf rlwrap-x.xx.tar.gz cd rlwrap-x.xx ./configure make sudo make install
注意:如果
./configure
脚本报告缺少依赖,则需要先安装这些依赖。
[root@racdb1 ~]# tar zxvf rlwrap-0.46.1.tar.gz
rlwrap-0.46.1/
rlwrap-0.46.1/BUGS
rlwrap-0.46.1/Makefile.am
rlwrap-0.46.1/configure.ac
rlwrap-0.46.1/ChangeLog
rlwrap-0.46.1/NEWS
rlwrap-0.46.1/test/
rlwrap-0.46.1/test/testclient
rlwrap-0.46.1/test/testit
rlwrap-0.46.1/config.h.in
rlwrap-0.46.1/completions/
rlwrap-0.46.1/completions/testclient
rlwrap-0.46.1/completions/coqtop
rlwrap-0.46.1/aclocal.m4
rlwrap-0.46.1/INSTALL
rlwrap-0.46.1/COPYING
rlwrap-0.46.1/Makefile.in
rlwrap-0.46.1/doc/
rlwrap-0.46.1/doc/Makefile.am
rlwrap-0.46.1/doc/Makefile.in
rlwrap-0.46.1/doc/rlwrap.man.in
rlwrap-0.46.1/filters/
rlwrap-0.46.1/filters/paint_prompt
rlwrap-0.46.1/filters/Makefile.am
rlwrap-0.46.1/filters/count_in_prompt
rlwrap-0.46.1/filters/null.py
rlwrap-0.46.1/filters/rlwrapfilter.py
rlwrap-0.46.1/filters/count_in_prompt.py
rlwrap-0.46.1/filters/unbackspace
rlwrap-0.46.1/filters/listing
rlwrap-0.46.1/filters/edit_history
rlwrap-0.46.1/filters/logger
rlwrap-0.46.1/filters/RlwrapFilter.pm
rlwrap-0.46.1/filters/makefilter
rlwrap-0.46.1/filters/handle_sigwinch
rlwrap-0.46.1/filters/ftp_filter
rlwrap-0.46.1/filters/censor_passwords
rlwrap-0.46.1/filters/outfilter
rlwrap-0.46.1/filters/pipeline
rlwrap-0.46.1/filters/README
rlwrap-0.46.1/filters/simple_macro
rlwrap-0.46.1/filters/Makefile.in
rlwrap-0.46.1/filters/handle_hotkeys
rlwrap-0.46.1/filters/null
rlwrap-0.46.1/filters/template
rlwrap-0.46.1/filters/handle_hotkeys.py
rlwrap-0.46.1/filters/ftp_filter.py
rlwrap-0.46.1/filters/dissect_prompt
rlwrap-0.46.1/filters/debug_null
rlwrap-0.46.1/filters/history_format
rlwrap-0.46.1/filters/paint_prompt.py
rlwrap-0.46.1/filters/RlwrapFilter.3pm
rlwrap-0.46.1/filters/pipeto.py
rlwrap-0.46.1/filters/scrub_prompt
rlwrap-0.46.1/filters/logger.py
rlwrap-0.46.1/filters/censor_passwords.py
rlwrap-0.46.1/filters/pipeto
rlwrap-0.46.1/configure
rlwrap-0.46.1/src/
rlwrap-0.46.1/src/multibyte.c
rlwrap-0.46.1/src/term.c
rlwrap-0.46.1/src/malloc_debug.c
rlwrap-0.46.1/src/Makefile.am
rlwrap-0.46.1/src/malloc_debug.h
rlwrap-0.46.1/src/signals.c
rlwrap-0.46.1/src/rlwrap.h
rlwrap-0.46.1/src/string_utils.c
rlwrap-0.46.1/src/pty.c
rlwrap-0.46.1/src/completion.rb
rlwrap-0.46.1/src/Makefile.in
rlwrap-0.46.1/src/redblack.h
rlwrap-0.46.1/src/readline.c
rlwrap-0.46.1/src/ptytty.c
rlwrap-0.46.1/src/filter.c
rlwrap-0.46.1/src/main.c
rlwrap-0.46.1/src/utils.c
rlwrap-0.46.1/src/completion.c
rlwrap-0.46.1/tools/
rlwrap-0.46.1/tools/config.sub
rlwrap-0.46.1/tools/install-sh
rlwrap-0.46.1/tools/config.guess
rlwrap-0.46.1/tools/test-driver
rlwrap-0.46.1/tools/depcomp
rlwrap-0.46.1/tools/missing
rlwrap-0.46.1/tools/compile
rlwrap-0.46.1/AUTHORS
rlwrap-0.46.1/README.md
[root@racdb1 ~]# cd rlwrap-0.46.1/
[root@racdb1 rlwrap-0.46.1]# ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
.......
hecking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating filters/Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating config.h
config.status: executing depfiles commands
Now do:
make (or gmake) to build rlwrap
make check for instructions how to test it
make install to install it
[root@racdb1 rlwrap-0.46.1]# make
[root@racdb1 rlwrap-0.46.1]# make install
[root@racdb1 rlwrap-0.46.1]# rlwrap --version
rlwrap 0.46.1
3. 验证安装
安装完成后,可以通过运行rlwrap --version
来验证rlwrap是否已成功安装,并查看其版本号。
二、配置rlwrap
1. 配置环境变量
为了方便使用,可以将rlwrap与特定的命令行工具(如sqlplus)结合使用,并为其设置别名。这通常通过修改用户的shell配置文件(如.bash_profile
、.bashrc
等)来实现。
- 打开shell配置文件,例如使用
vi ~/.bash_profile
。 - 在文件末尾添加别名,例如:
alias sqlplus='rlwrap sqlplus' alias rman='rlwrap rman'
- 保存并关闭文件。
- 使更改生效,可以通过运行
source ~/.bash_profile
或重新登录shell会话来实现。
2. 使用rlwrap
配置完成后,就可以通过别名来启动sqlplus或其他命令行工具了。此时,你将能够使用退格键、方向键等编辑功能,以及命令历史记录等特性。
三、注意事项
- 在安装和配置rlwrap时,请确保你有足够的权限来执行相关命令(如使用sudo)。
- 如果在安装过程中遇到任何问题(如缺少依赖、编译错误等),请查阅rlwrap的官方文档或搜索相关的解决方案。
- rlwrap的版本和依赖库可能会随着操作系统的更新而发生变化,因此请确保你下载的是与你的操作系统兼容的版本。
以上就是rlwrap的安装和配置步骤。希望这些信息对你有所帮助!