【rlwrap】Linux上實現Windows的SQL*Plus儲存SQL歷史記錄功能
1.rlwrap介紹
rlwrap is a 'readline wrapper' that uses the GNU readline library to allow the editing of keyboard input for any other command. Input history is remembered across invocations, separately for each command; history completion and search work as in bash and completion word lists can be specified on the command line.
rlwrap runs the specified command, intercepting user input in order to provide readline’s line editing, persistent history and completion. rlwrap tries to be as transparent as possible, keeping track of command’s terminal settings, so that it can do the right thing when command asks for single keypresses or for a password.
大家應該都知道,在Windows作業系統上可以使用上下鍵來呼叫曾經使用過的SQL命令,這樣可以比較方便的編輯曾經輸入過的命令。因為SQL*Plus只是記錄最近執行的一條sql命令,所以Windows上的這個功能給不少在Windows上操作SQL的朋友帶來了很大的便利。
突然,有一天(早晚有一天),您發現Windows上這個功能在Linux上不復存在,心中不免有些惆悵。
這時,您有兩種選擇,
第一種選擇是:慢慢適應Linux下SQL*Plus的操作習慣,以Vi編輯器與edit命令結合編輯最近一條使用的SQL(This is a good method.);
第二種選擇是:尋找第三方的小工具來滿足這個從Windows上繼承下來的“弊病”,這個小文兒就來介紹這樣一個輔助小工具,它的名字叫做rlwrap=“readline wrapper”。
本人不建議將這些“小把戲”在生產環境上部署,生產環境應該避免一切“花哨”的設定,否則一旦遇到“潛規則”您可能會死的很壯烈:)
下面就來給大家介紹一下這個小工具。
2.下載rlwrap
下載地址:
%7Ehlub/uck/rlwrap/rlwrap-0.30.tar.gz
~hlub/uck/rlwrap/
先將這個軟體(我使用的時候版本是0.30)下載到本地電腦上。
3.從本地電腦將安裝介質上傳到待安裝的伺服器上
$ scp rlwrap-0.30.tar.gz root@144.194.192.183:~
root@144.194.192.183's password:
rlwrap-0.30.tar.gz 100% 180KB 179.7KB/s 00:00
4.解壓該安裝介質
[root@testdb183 ~]# gzip -d rlwrap-0.30.tar.gz
[root@testdb183 ~]# tar -xvf rlwrap-0.30.tar
rlwrap-0.30/
rlwrap-0.30/completions/
rlwrap-0.30/completions/ftp
rlwrap-0.30/completions/testclient
rlwrap-0.30/completions/coqtop
rlwrap-0.30/distribution/
rlwrap-0.30/distribution/rlwrap.spec.in
rlwrap-0.30/doc/
rlwrap-0.30/doc/rlwrap.man.in
rlwrap-0.30/doc/Makefile.am
rlwrap-0.30/doc/Makefile.in
rlwrap-0.30/src/
rlwrap-0.30/src/rlwrap.h
rlwrap-0.30/src/redblack.h
rlwrap-0.30/src/malloc_debug.h
rlwrap-0.30/src/completion.rb
rlwrap-0.30/src/Makefile.am
rlwrap-0.30/src/Makefile.in
rlwrap-0.30/src/main.c
rlwrap-0.30/src/signals.c
rlwrap-0.30/src/readline.c
rlwrap-0.30/src/pty.c
rlwrap-0.30/src/completion.c
rlwrap-0.30/src/term.c
rlwrap-0.30/src/ptytty.c
rlwrap-0.30/src/utils.c
rlwrap-0.30/src/string_utils.c
rlwrap-0.30/src/malloc_debug.c
rlwrap-0.30/test/
rlwrap-0.30/test/testclient
rlwrap-0.30/test/testit
rlwrap-0.30/tools/
rlwrap-0.30/tools/config.guess
rlwrap-0.30/tools/config.sub
rlwrap-0.30/tools/depcomp
rlwrap-0.30/tools/install-sh
rlwrap-0.30/tools/missing
rlwrap-0.30/tools/mkinstalldirs
rlwrap-0.30/README
rlwrap-0.30/configure.ac
rlwrap-0.30/aclocal.m4
rlwrap-0.30/Makefile.am
rlwrap-0.30/Makefile.in
rlwrap-0.30/config.h.in
rlwrap-0.30/configure
rlwrap-0.30/AUTHORS
rlwrap-0.30/COPYING
rlwrap-0.30/ChangeLog
rlwrap-0.30/INSTALL
rlwrap-0.30/NEWS
rlwrap-0.30/TODO
rlwrap-0.30/BUGS
[root@testdb183 ~]#
5.安裝rlwrap
1)使用加壓目錄中的configure檔案進行配置
[root@testdb183 rlwrap-0.30]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-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 for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... (cached) yes
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 for style. of include used by make... GNU
checking dependency style. of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for perl... /usr/bin/perl
checking for strip... strip
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/wait.h that is POSIX.1 compatible... 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 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 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 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 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 curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking ncurses/term.h usability... yes
checking ncurses/term.h presence... yes
checking for ncurses/term.h... yes
checking whether term.h exists and compiles... yes
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 select... yes
checking for snprintf... yes
checking for strlcpy... no
checking for strlcat... no
checking for strnlen... yes
checking for sched_yield... yes
checking for getopt_long... (cached) yes
checking for setsid... yes
checking for isastream... yes
checking for mkstemp... yes
checking for system... yes
checking for readlink... yes
checking for setenv... yes
checking for putenv... 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... yes
checking whether your readline knows about rl_set_screen_size... yes
checking whether your readline knows about rl_variable_value... yes
checking whether your readline knows about rl_readline_version... yes
Will rlwrap find command's working directory under /proc//cwd? let's see...
checking for /proc/18843/cwd/configure.ac... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating distribution/rlwrap.spec
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
2)使用make進行編譯
[root@testdb183 rlwrap-0.30]# make
make all-recursive
make[1]: Entering directory `/root/rlwrap-0.30'
Making all in doc
make[2]: Entering directory `/root/rlwrap-0.30/doc'
sed -e 's#@DATADIR@#/usr/local/share#' rlwrap.man > rlwrap.1
make[2]: Leaving directory `/root/rlwrap-0.30/doc'
Making all in src
make[2]: Entering directory `/root/rlwrap-0.30/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
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 -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 -lutil -lreadline -lcurses
make[2]: Leaving directory `/root/rlwrap-0.30/src'
make[2]: Entering directory `/root/rlwrap-0.30'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/root/rlwrap-0.30'
make[1]: Leaving directory `/root/rlwrap-0.30'
3)使用“make install”進行最後一步的安裝
[root@testdb183 rlwrap-0.30]# make install
Making install in doc
make[1]: Entering directory `/root/rlwrap-0.30/doc'
make[2]: Entering directory `/root/rlwrap-0.30/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/rlwrap.1'
make[2]: Leaving directory `/root/rlwrap-0.30/doc'
make[1]: Leaving directory `/root/rlwrap-0.30/doc'
Making install in src
make[1]: Entering directory `/root/rlwrap-0.30/src'
make[2]: Entering directory `/root/rlwrap-0.30/src'
test -z "/usr/local/bin" || /bin/mkdir -p "/usr/local/bin"
/usr/bin/install -c 'rlwrap' '/usr/local/bin/rlwrap'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/rlwrap-0.30/src'
make[1]: Leaving directory `/root/rlwrap-0.30/src'
make[1]: Entering directory `/root/rlwrap-0.30'
make[2]: Entering directory `/root/rlwrap-0.30'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/share/rlwrap" || /bin/mkdir -p "/usr/local/share/rlwrap"
/usr/bin/install -c -m 644 'completions/ftp' '/usr/local/share/rlwrap/ftp'
/usr/bin/install -c -m 644 'completions/testclient' '/usr/local/share/rlwrap/testclient'
/usr/bin/install -c -m 644 'completions/coqtop' '/usr/local/share/rlwrap/coqtop'
make[2]: Leaving directory `/root/rlwrap-0.30'
make[1]: Leaving directory `/root/rlwrap-0.30'
6.使用rlwrap命令方法
可以參考它的man幫助頁:~hlub/uck/rlwrap/man.html
或使用“-h”選項檢視簡單的幫助資訊
ora10g@testdb183 /home/oracle$ rlwrap -h
Usage: rlwrap [options] command ...
Options:
-a[password:] --always-readline[=password:]
-A --ansi-colour-aware
-b --break-chars=
-c --complete-filenames
-C --command-name=
-D <0|1|2> --history-no-dupes=<0|1|2>
-f --file=
-F --history-format=
-h --help
-H --history-filename=
-i --case-insensitive
-l --logfile=
-n --no-warnings
-p[ANSI colour spec] --prompt-colour[=ANSI colour spec]
-P --pre-given=
-q --quote-characters=
-m[newline substitute] --multi-line[=newline substitute]
-r --remember
-v --version
-s --histsize= (negative: readonly)
-t --set-term-name=
bug reports, suggestions, updates:
~hlub/uck/rlwrap/
上面的資訊有點複雜了,其實我們很簡單,只要在輸入sqlplus之前加上rlwrap就可以了。演示如下:
ora10g@testdb183 /home/oracle$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Mon Sep 7 14:23:43 2009
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
sys@ora10g>
OK,到此,已經進入到了sqlplus中,從今往後,在這裡輸入的任何的單行資訊都會被記錄(即使是你輸入錯誤的命令也會被記錄,它的策略很簡單)。
使用上下箭頭就可以呼叫之前曾經輸入過的SQL命令啦。
7.rlwrap工具使用特點
1)即使退出重新登陸到sqlplus或rman中,之前的命令仍然被記錄,仍然可被使用
2)這只是一個按行進行記錄的工具,如果您的SQL是多行組成的,使用這個上下箭頭來檢視歷史命令就不是很方便了。還是要使用edit命令呼叫Vi或Vim來進行編輯來的直接一些。
8.小結
rlwrap工具不但可以記錄sqlplus命令,而且可以記錄rman命令,使設定永久生效的方法是,將下面的同名放入到使用者配置檔案(Linux是~/.bash_profile)中。
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
Pls enjoy it.
secooler
09.09.07
-- The End --
rlwrap is a 'readline wrapper' that uses the GNU readline library to allow the editing of keyboard input for any other command. Input history is remembered across invocations, separately for each command; history completion and search work as in bash and completion word lists can be specified on the command line.
rlwrap runs the specified command, intercepting user input in order to provide readline’s line editing, persistent history and completion. rlwrap tries to be as transparent as possible, keeping track of command’s terminal settings, so that it can do the right thing when command asks for single keypresses or for a password.
大家應該都知道,在Windows作業系統上可以使用上下鍵來呼叫曾經使用過的SQL命令,這樣可以比較方便的編輯曾經輸入過的命令。因為SQL*Plus只是記錄最近執行的一條sql命令,所以Windows上的這個功能給不少在Windows上操作SQL的朋友帶來了很大的便利。
突然,有一天(早晚有一天),您發現Windows上這個功能在Linux上不復存在,心中不免有些惆悵。
這時,您有兩種選擇,
第一種選擇是:慢慢適應Linux下SQL*Plus的操作習慣,以Vi編輯器與edit命令結合編輯最近一條使用的SQL(This is a good method.);
第二種選擇是:尋找第三方的小工具來滿足這個從Windows上繼承下來的“弊病”,這個小文兒就來介紹這樣一個輔助小工具,它的名字叫做rlwrap=“readline wrapper”。
本人不建議將這些“小把戲”在生產環境上部署,生產環境應該避免一切“花哨”的設定,否則一旦遇到“潛規則”您可能會死的很壯烈:)
下面就來給大家介紹一下這個小工具。
2.下載rlwrap
下載地址:
%7Ehlub/uck/rlwrap/rlwrap-0.30.tar.gz
~hlub/uck/rlwrap/
先將這個軟體(我使用的時候版本是0.30)下載到本地電腦上。
3.從本地電腦將安裝介質上傳到待安裝的伺服器上
$ scp rlwrap-0.30.tar.gz root@144.194.192.183:~
root@144.194.192.183's password:
rlwrap-0.30.tar.gz 100% 180KB 179.7KB/s 00:00
4.解壓該安裝介質
[root@testdb183 ~]# gzip -d rlwrap-0.30.tar.gz
[root@testdb183 ~]# tar -xvf rlwrap-0.30.tar
rlwrap-0.30/
rlwrap-0.30/completions/
rlwrap-0.30/completions/ftp
rlwrap-0.30/completions/testclient
rlwrap-0.30/completions/coqtop
rlwrap-0.30/distribution/
rlwrap-0.30/distribution/rlwrap.spec.in
rlwrap-0.30/doc/
rlwrap-0.30/doc/rlwrap.man.in
rlwrap-0.30/doc/Makefile.am
rlwrap-0.30/doc/Makefile.in
rlwrap-0.30/src/
rlwrap-0.30/src/rlwrap.h
rlwrap-0.30/src/redblack.h
rlwrap-0.30/src/malloc_debug.h
rlwrap-0.30/src/completion.rb
rlwrap-0.30/src/Makefile.am
rlwrap-0.30/src/Makefile.in
rlwrap-0.30/src/main.c
rlwrap-0.30/src/signals.c
rlwrap-0.30/src/readline.c
rlwrap-0.30/src/pty.c
rlwrap-0.30/src/completion.c
rlwrap-0.30/src/term.c
rlwrap-0.30/src/ptytty.c
rlwrap-0.30/src/utils.c
rlwrap-0.30/src/string_utils.c
rlwrap-0.30/src/malloc_debug.c
rlwrap-0.30/test/
rlwrap-0.30/test/testclient
rlwrap-0.30/test/testit
rlwrap-0.30/tools/
rlwrap-0.30/tools/config.guess
rlwrap-0.30/tools/config.sub
rlwrap-0.30/tools/depcomp
rlwrap-0.30/tools/install-sh
rlwrap-0.30/tools/missing
rlwrap-0.30/tools/mkinstalldirs
rlwrap-0.30/README
rlwrap-0.30/configure.ac
rlwrap-0.30/aclocal.m4
rlwrap-0.30/Makefile.am
rlwrap-0.30/Makefile.in
rlwrap-0.30/config.h.in
rlwrap-0.30/configure
rlwrap-0.30/AUTHORS
rlwrap-0.30/COPYING
rlwrap-0.30/ChangeLog
rlwrap-0.30/INSTALL
rlwrap-0.30/NEWS
rlwrap-0.30/TODO
rlwrap-0.30/BUGS
[root@testdb183 ~]#
5.安裝rlwrap
1)使用加壓目錄中的configure檔案進行配置
[root@testdb183 rlwrap-0.30]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-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 for a BSD-compatible install... /usr/bin/install -c
checking whether make sets $(MAKE)... (cached) yes
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 for style. of include used by make... GNU
checking dependency style. of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for perl... /usr/bin/perl
checking for strip... strip
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/wait.h that is POSIX.1 compatible... 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 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 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 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 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 curses.h usability... yes
checking curses.h presence... yes
checking for curses.h... yes
checking ncurses/term.h usability... yes
checking ncurses/term.h presence... yes
checking for ncurses/term.h... yes
checking whether term.h exists and compiles... yes
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 select... yes
checking for snprintf... yes
checking for strlcpy... no
checking for strlcat... no
checking for strnlen... yes
checking for sched_yield... yes
checking for getopt_long... (cached) yes
checking for setsid... yes
checking for isastream... yes
checking for mkstemp... yes
checking for system... yes
checking for readlink... yes
checking for setenv... yes
checking for putenv... 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... yes
checking whether your readline knows about rl_set_screen_size... yes
checking whether your readline knows about rl_variable_value... yes
checking whether your readline knows about rl_readline_version... yes
Will rlwrap find command's working directory under /proc/
checking for /proc/18843/cwd/configure.ac... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating src/Makefile
config.status: creating doc/rlwrap.man
config.status: creating distribution/rlwrap.spec
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
2)使用make進行編譯
[root@testdb183 rlwrap-0.30]# make
make all-recursive
make[1]: Entering directory `/root/rlwrap-0.30'
Making all in doc
make[2]: Entering directory `/root/rlwrap-0.30/doc'
sed -e 's#@DATADIR@#/usr/local/share#' rlwrap.man > rlwrap.1
make[2]: Leaving directory `/root/rlwrap-0.30/doc'
Making all in src
make[2]: Entering directory `/root/rlwrap-0.30/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
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 -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 -lutil -lreadline -lcurses
make[2]: Leaving directory `/root/rlwrap-0.30/src'
make[2]: Entering directory `/root/rlwrap-0.30'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/root/rlwrap-0.30'
make[1]: Leaving directory `/root/rlwrap-0.30'
3)使用“make install”進行最後一步的安裝
[root@testdb183 rlwrap-0.30]# make install
Making install in doc
make[1]: Entering directory `/root/rlwrap-0.30/doc'
make[2]: Entering directory `/root/rlwrap-0.30/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/rlwrap.1'
make[2]: Leaving directory `/root/rlwrap-0.30/doc'
make[1]: Leaving directory `/root/rlwrap-0.30/doc'
Making install in src
make[1]: Entering directory `/root/rlwrap-0.30/src'
make[2]: Entering directory `/root/rlwrap-0.30/src'
test -z "/usr/local/bin" || /bin/mkdir -p "/usr/local/bin"
/usr/bin/install -c 'rlwrap' '/usr/local/bin/rlwrap'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/rlwrap-0.30/src'
make[1]: Leaving directory `/root/rlwrap-0.30/src'
make[1]: Entering directory `/root/rlwrap-0.30'
make[2]: Entering directory `/root/rlwrap-0.30'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/share/rlwrap" || /bin/mkdir -p "/usr/local/share/rlwrap"
/usr/bin/install -c -m 644 'completions/ftp' '/usr/local/share/rlwrap/ftp'
/usr/bin/install -c -m 644 'completions/testclient' '/usr/local/share/rlwrap/testclient'
/usr/bin/install -c -m 644 'completions/coqtop' '/usr/local/share/rlwrap/coqtop'
make[2]: Leaving directory `/root/rlwrap-0.30'
make[1]: Leaving directory `/root/rlwrap-0.30'
6.使用rlwrap命令方法
可以參考它的man幫助頁:~hlub/uck/rlwrap/man.html
或使用“-h”選項檢視簡單的幫助資訊
ora10g@testdb183 /home/oracle$ rlwrap -h
Usage: rlwrap [options] command ...
Options:
-a[password:] --always-readline[=password:]
-A --ansi-colour-aware
-b
-c --complete-filenames
-C
-D <0|1|2> --history-no-dupes=<0|1|2>
-f
-F
-h --help
-H
-i --case-insensitive
-l
-n --no-warnings
-p[ANSI colour spec] --prompt-colour[=ANSI colour spec]
-P --pre-given=
-q
-m[newline substitute] --multi-line[=newline substitute]
-r --remember
-v --version
-s
-t
bug reports, suggestions, updates:
~hlub/uck/rlwrap/
上面的資訊有點複雜了,其實我們很簡單,只要在輸入sqlplus之前加上rlwrap就可以了。演示如下:
ora10g@testdb183 /home/oracle$ rlwrap sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Mon Sep 7 14:23:43 2009
Copyright (c) 1982, 2006, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
sys@ora10g>
OK,到此,已經進入到了sqlplus中,從今往後,在這裡輸入的任何的單行資訊都會被記錄(即使是你輸入錯誤的命令也會被記錄,它的策略很簡單)。
使用上下箭頭就可以呼叫之前曾經輸入過的SQL命令啦。
7.rlwrap工具使用特點
1)即使退出重新登陸到sqlplus或rman中,之前的命令仍然被記錄,仍然可被使用
2)這只是一個按行進行記錄的工具,如果您的SQL是多行組成的,使用這個上下箭頭來檢視歷史命令就不是很方便了。還是要使用edit命令呼叫Vi或Vim來進行編輯來的直接一些。
8.小結
rlwrap工具不但可以記錄sqlplus命令,而且可以記錄rman命令,使設定永久生效的方法是,將下面的同名放入到使用者配置檔案(Linux是~/.bash_profile)中。
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
Pls enjoy it.
secooler
09.09.07
-- The End --
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/519536/viewspace-614104/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Linux上實現Windows的SQL*Plus儲存SQL歷史記錄功能---rlwrap(轉)LinuxWindowsSQL
- solaris下配置使用SQL*Plus歷史命令記錄SQL
- LINUX下SQLPLUS等工具的歷史記錄功能LinuxSQL
- 使用SQL SERVER儲存過程實現歷史資料遷移SQLServer儲存過程
- 實現使用者的歷史記錄功能
- rlwrap實現鍵盤上下箭頭,調出歷史執行的SQL命令SQL
- rlwrap - 支援oracle下sqlplus歷史命令的回撥功能OracleSQL
- 視訊直播原始碼,實現本地儲存搜尋歷史記錄原始碼
- 查詢SQL Server的歷史執行記錄SQLServer
- 利用Uniread 解決 Linux下的SQL*Plus 命令列歷史回撥功能LinuxSQL命令列
- linux下sqlplus調出歷史命令--rlwrap介紹LinuxSQL
- linux 下sqlplus 歷史記錄問題LinuxSQL
- rlwrap,找回原來的那個SQL*PlusSQL
- Android EditText輸入框實現下拉且儲存最近5個歷史記錄Android
- oracle實驗記錄 (SQL*PLUS 命令操作)OracleSQL
- py程式設計技巧-1.7-如何實現使用者歷史記錄儲存(最多n條)程式設計
- 【SQL*Plus】11g版本對 SQL*Plus錯誤日誌的記錄功能——errorlogging引數SQLError
- Linux下mysql的歷史操作記錄LinuxMySql
- 雲伺服器清除 SQL 伺服器名稱歷史記錄伺服器SQL
- win10執行記錄不儲存怎麼辦 win10執行儲存歷史記錄設定方法Win10
- QQ聊天記錄儲存如何實現?
- SQL Server 深入解析索引儲存(上)SQLServer索引
- 在linux下使SQLPLUS歷史回撥功能LinuxSQL
- 在Linux下使用SQLPLUS歷史回撥功能LinuxSQL
- Linux中多種方法實時記錄歷史命令Linux
- 在windows上,Vim 與 SQL*Plus 結合使用WindowsSQL
- Linux檢視歷史記錄小技巧Linux
- Linux中禁用命令歷史記錄Linux
- SQL Server 查詢歷史執行的SQL語句SQLServer
- SQL Server與MySQL儲存過程學習記錄之一ServerMySql儲存過程
- 在博物館裡儲存遊戲歷史有多難?(上)遊戲
- rlwrap sqlplus in linuxSQLLinux
- Oracle檢視歷史TOP SQLOracleSQL
- Win10執行無法儲存歷史記錄怎麼辦 win10開始執行記錄不儲存如何解決Win10
- 修改Kali Linux終端歷史記錄大小Linux
- Oracle中檢視sql命令歷史,檢視rman命令歷史OracleSQL
- Mac貼上板歷史儲存管理軟體——CopyClip 2 for MacMac
- 用pandas實現SQL功能SQL