Debian 10 达梦数据库 disql工具输入命令 左右移动光标乱码

1、下载安装包rlwrap-0.46.1

https://github.com/hanslub42/rlwrap/releases/download/0.46.1/rlwrap-0.46.1.tar.gz
在这里插入图片描述

2、编译安装rlwrap-0.46.1

2.0、依赖包查找

重要:需提前安装依赖包,否则编译会出现错误
You need the GNU readline library(ftp://ftp.gnu.org/gnu/readline/ ) to build this program!

在这里插入图片描述

2.0.1、解决思路

查看源码目录下的INSTALL文件
在这里插入图片描述
得知需要安装readline-dev
因为系统上已经存在了readline相关包,还是编译不成功。所以去寻求安装readline-dev

root@debian:/usr/local/src/rlwrap-0.46.1# dpkg -l|grep readli
ii  readline-common                       7.0-5                                        all          GNU readline and history libraries, common files
ii  readline-doc                          7.0-5                                        all          GNU readline and history libraries, documentation and examples
root@debian:/usr/local/src/rlwrap-0.46.1#

搜索readline-dev

apt search --names-only readline-dev

在这里插入图片描述

2.1、依赖包安装

apt install readline*
apt install libreadline-dev

2.2、编译安装

tar -zxvf rlwrap-0.46.1.tar.gz -C /usr/local/src/
cd /usr/local/src/rlwrap-0.46.1/
mkdir /usr/local/rlwrap-0.46.1
./configure --prefix=/usr/local/rlwrap-0.46.1/ && make && make install

2.3、安装成功

root@debian:/usr/local/src/rlwrap-0.46.1# ./configure --prefix=/usr/local/rlwrap-0.46.1/ && make && make install
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
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make sets $(MAKE)... (cached) yes
checking whether build environment is sane... yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether gcc accepts -g... yes
checking for gcc option to enable C11 features... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking for wchar.h... yes
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking whether _XOPEN_SOURCE should be defined... no
checking for gcc... (cached) gcc
checking whether the compiler supports GNU C... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to enable C11 features... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
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 sys/wait.h that is POSIX.1 compatible... yes
checking for errno.h... yes
checking for fcntl.h... yes
checking for libgen.h... yes
checking for libutil.h... no
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for sched.h... yes
checking for sys/file.h... yes
checking for sys/ioctl.h... yes
checking for sys/wait.h... (cached) yes
checking for sys/resource.h... yes
checking for stddef.h... yes
checking for termios.h... yes
checking for unistd.h... (cached) yes
checking for stdint.h... (cached) yes
checking for time.h... yes
checking for sys/time.h... yes
checking for getopt.h... yes
checking for regex.h... yes
checking for curses.h... yes
checking for stropts.h... yes
checking for termcap.h... yes
checking for util.h... no
checking for term.h... yes
checking for ncurses/term.h... no
checking for gcc options needed to detect all undeclared functions... none needed
checking whether PROC_PIDVNODEPATHINFO is declared... no
checking whether procstat_open_sysctl is declared... no
checking whether procstat_getprocs is declared... no
checking whether procstat_getfiles is declared... no
checking whether STAILQ_FOREACH is declared... no
checking argument type of tputs putc function... int
checking for an ANSI C-conforming const... yes
checking for pid_t... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking whether gcc needs -traditional... no
checking for getopt_long... yes
checking for basename... yes
checking for dirname... yes
checking for flock... yes
checking for getopt_long... (cached) yes
checking for isastream... yes
checking for mkstemps... 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... 
checking for pty/tty type... checking for pty.h... yes
OPENPTY
configure: checking for pty ranges
checking for tgetent... no
checking for tgetent in -ltinfo... yes
checking for readline in -lreadline... yes
checking for tigetnum... yes
checking for readline/readline.h... yes
checking whether your readline headers and library know about rl_set_screen_size... yes
checking whether your readline headers and library know about rl_basic_quote_characters... yes
checking whether your readline headers and library know about rl_variable_value... yes
checking whether your readline headers and library know about rl_readline_version... yes
checking whether your readline headers and library know about rl_executing_keyseq... yes
checking whether the private symbol _rl_horizontal_scroll_mode is visble in your readline libs... yes
Will rlwrap find command's working directory under /proc/<commands pid>/cwd? let's see...
checking for /proc/7590/cwd/configure.ac... yes
checking whether we can find command line under <opt_proc_mountpoint>/<pid>/cmdline and mirror it by overwriting our own *argv (this may take a few secs)... yes


checking that generated files are newer than configure... done
checking 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

make  all-recursive
make[1]: Entering directory '/usr/local/src/rlwrap-0.46.1'
Making all in doc
make[2]: Entering directory '/usr/local/src/rlwrap-0.46.1/doc'
sed -e 's#@DATADIR@#/usr/local/rlwrap-0.46.1/share#'  rlwrap.man > rlwrap.1
make[2]: Leaving directory '/usr/local/src/rlwrap-0.46.1/doc'
Making all in src
make[2]: Entering directory '/usr/local/src/rlwrap-0.46.1/src'
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/rlwrap-0.46.1/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/rlwrap-0.46.1/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/rlwrap-0.46.1/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/rlwrap-0.46.1/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/rlwrap-0.46.1/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/rlwrap-0.46.1/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/rlwrap-0.46.1/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/rlwrap-0.46.1/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/rlwrap-0.46.1/share\"  -g -O2 -MT string_utils.o -MD -MP -MF .deps/string_utils.Tpo -c -o string_utils.o string_utils.c
mv -f .deps/string_utils.Tpo .deps/string_utils.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/rlwrap-0.46.1/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/rlwrap-0.46.1/share\"  -g -O2 -MT multibyte.o -MD -MP -MF .deps/multibyte.Tpo -c -o multibyte.o multibyte.c
mv -f .deps/multibyte.Tpo .deps/multibyte.Po
gcc -DHAVE_CONFIG_H -I. -I..    -DDATADIR=\"/usr/local/rlwrap-0.46.1/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/rlwrap-0.46.1/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 multibyte.o filter.o  -lutil   -lreadline -ltinfo
make[2]: Leaving directory '/usr/local/src/rlwrap-0.46.1/src'
Making all in filters
make[2]: Entering directory '/usr/local/src/rlwrap-0.46.1/filters'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/usr/local/src/rlwrap-0.46.1/filters'
make[2]: Entering directory '/usr/local/src/rlwrap-0.46.1'
make[2]: Leaving directory '/usr/local/src/rlwrap-0.46.1'
make[1]: Leaving directory '/usr/local/src/rlwrap-0.46.1'
Making install in doc
make[1]: Entering directory '/usr/local/src/rlwrap-0.46.1/doc'
make[2]: Entering directory '/usr/local/src/rlwrap-0.46.1/doc'
make[2]: Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/rlwrap-0.46.1/share/man/man1'
 /usr/bin/install -c -m 644 rlwrap.1 '/usr/local/rlwrap-0.46.1/share/man/man1'
make[2]: Leaving directory '/usr/local/src/rlwrap-0.46.1/doc'
make[1]: Leaving directory '/usr/local/src/rlwrap-0.46.1/doc'
Making install in src
make[1]: Entering directory '/usr/local/src/rlwrap-0.46.1/src'
make[2]: Entering directory '/usr/local/src/rlwrap-0.46.1/src'
 /usr/bin/mkdir -p '/usr/local/rlwrap-0.46.1/bin'
  /usr/bin/install -c rlwrap '/usr/local/rlwrap-0.46.1/bin'
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/usr/local/src/rlwrap-0.46.1/src'
make[1]: Leaving directory '/usr/local/src/rlwrap-0.46.1/src'
Making install in filters
make[1]: Entering directory '/usr/local/src/rlwrap-0.46.1/filters'
make[2]: Entering directory '/usr/local/src/rlwrap-0.46.1/filters'
make[2]: Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/rlwrap-0.46.1/share/man/man3'
 /usr/bin/install -c -m 644 RlwrapFilter.3pm '/usr/local/rlwrap-0.46.1/share/man/man3'
make[2]: Leaving directory '/usr/local/src/rlwrap-0.46.1/filters'
make[1]: Leaving directory '/usr/local/src/rlwrap-0.46.1/filters'
make[1]: Entering directory '/usr/local/src/rlwrap-0.46.1'
make[2]: Entering directory '/usr/local/src/rlwrap-0.46.1'
make[2]: Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/rlwrap-0.46.1/share/rlwrap'
 /usr/bin/mkdir -p '/usr/local/rlwrap-0.46.1/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/handle_hotkeys filters/history_format filters/simple_macro filters/template filters/scrub_prompt filters/paint_prompt filters/censor_passwords filters/listing filters/paint_prompt.py filters/handle_hotkeys.py filters/logger.py filters/pipeto.py filters/rlwrapfilter.py filters/null.py filters/censor_passwords.py filters/edit_history filters/count_in_prompt.py filters/ftp_filter.py filters/debug_null filters/handle_sigwinch filters/outfilter filters/makefilter filters/dissect_prompt '/usr/local/rlwrap-0.46.1/share/rlwrap/filters'
 /usr/bin/mkdir -p '/usr/local/rlwrap-0.46.1/share/rlwrap/completions'
 /usr/bin/install -c -m 644  completions/testclient completions/coqtop '/usr/local/rlwrap-0.46.1/share/rlwrap/completions'
make  install-data-hook
make[3]: Entering directory '/usr/local/src/rlwrap-0.46.1'
chmod a+x /usr/local/rlwrap-0.46.1/share/rlwrap/filters/* 
make[3]: Leaving directory '/usr/local/src/rlwrap-0.46.1'
make[2]: Leaving directory '/usr/local/src/rlwrap-0.46.1'
make[1]: Leaving directory '/usr/local/src/rlwrap-0.46.1'
root@debian:/usr/local/src/rlwrap-0.46.1# 

查看安装目录

root@debian:/usr/local/src/rlwrap-0.46.1# ls -l /usr/local/rlwrap-0.46.1/
total 8
drwxr-xr-x 2 root root 4096 Apr  3 20:07 bin
drwxr-xr-x 4 root root 4096 Apr  3 20:07 share
root@debian:/usr/local/src/rlwrap-0.46.1# 

3、设置rlwrap系统环境变量

vi /etc/profile
添加一行
PATH=/usr/local/rlwrap-0.46.1/bin:$PATH
source /etc/profile

root@debian:/usr/local/src/rlwrap-0.46.1# rlwrap --help
Usage: rlwrap [options] command ...

Options:
  -a[password prompt]        --always-readline[=password prompt]
  -A                         --ansi-colour-aware
  -b  <chars>                --break-chars=<chars>
  -c                         --complete-filenames
  -C  <name|N>               --command-name=<name|N>
  -D  <0|1|2>                --history-no-dupes=<0|1|2>
  -e  <char|''>              --extra-char-after-completion=<char|''>
  -f  <completion list>      --file=<completion list>
  -g  <regexp>               --forget-matching=<regexp>
  -h                         --help
  -H  <file>                 --history-filename=<file>
  -i                         --case-insensitive
  -I                         --pass-sigint-as-sigterm
  -l  <file>                 --logfile=<file>
  -m[newline substitute]     --multi-line[=newline substitute]
  -M  <.ext>                 --multi-line-ext=<.ext>
  -n                         --no-warnings
  -N                         --no-children
  -o                         --one-shot
  -O  <regexp>               --only-cook=<regexp>
  -p[colour]                 --prompt-colour[=colour]
  -P  <input>                --pre-given=<input>
  -q  <chars>                --quote-characters=<chars>
  -r                         --remember
  -R                         --renice
  -s  <N>                    --histsize=<N> (negative: readonly)
  -S  <prompt>               --substitute-prompt=<prompt>
  -t  <name>                 --set-term-name=<name>
  -U                         --mirror-arguments
  -v                         --version
  -w  <N>                    --wait-before-prompt=<N> (msec, <0  : patient mode)
  -W                         --polling
  -z  <filter command>       --filter=<filter command> ('rlwrap -z listing' writes a list of installed filters)

bug reports, suggestions, updates:
https://github.com/hanslub42/rlwrap
root@debian:/usr/local/src/rlwrap-0.46.1# rlwrap -v
rlwrap 0.46.1
root@debian:/usr/local/src/rlwrap-0.46.1# 

4、配置达梦护数据库用户环境变量

安装成功后,配置 dmdba 用户(安装 DM8 软件的用户)环境变量

su - dmdba
vi .bash_profile 

编辑文件,在文件最后增加如下两行。

alias disql="rlwrap disql"
alias dmrman="rlwrap dmrman"

在这里插入图片描述
使环境变量生效

dmdba@debian:~$ source .bash_profile

5、测试效果

再使用disql或dmrman 命令,即可使用上下左右按键来修改、删除sql语句或者查询历史sql语句,就方便了很多。

SQL> describe testDM8

行号     NAME   TYPE$   NULLABLE
---------- ------ ------- --------
1          ID     INTEGER Y
2          NUMBER INTEGER Y

已用时间: 24.968(毫秒). 执行号:600.
SQL> insert into testDM8 values (1,001);
影响行数 1

已用时间: 1.093(毫秒). 执行号:601.
SQL> select * from testDM8;

行号     ID          NUMBER     
---------- ----------- -----------
1          1           1

已用时间: 1.031(毫秒). 执行号:602.
SQL> 

猜你喜欢

转载自blog.csdn.net/OceanWaves1993/article/details/129947298