『安裝配置』用rlwrap解決SSH中使用SQLPLUS的方向鍵的問題

  • I’ve been trying to follow your advice and use Linux for my Oracle learning environment instead of Windows. But it’s practically unworkable! In Windows, I can up-arrow in SQL*Plus and retrieve old commands, make one or two edits and re-submit. But in Linux I can’t, I just have to type them in all over again from scratch. This is madness!!

I agree it’s madness, and it has driven me completely bonkers many a time, so you’re not alone. But you will be relieved to know that help is on its way, thanks to a former colleague of mine, Paul Burgess, for having discovered one of the nicest little utilities for Linux that I know of... and letting me in on the secret.

What you must get your hands on is a tiny program called RLWRAP. It’s only 24K in size, and you can download it here. If you wish to check for a more up-to-date version (this document was written in November 2004), then try here. Once it's downloaded, install it as you would any rpm. That is, as root, issue the command

rpm -ivh rlwrap-0.18-1.i386.rpm

For the program to take effect, you must then edit the .bashrc file for the Oracle user (and any other user who is to run SQL*Plus regularly), so that it contains the lines:

alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'

...and if you want to put a command line history into any other Oracle program, you simply alias the program in the same way (hence: alias exp=’rlwrap exp’ for export, and alias lsnrctl=’rlwrap lsnrctl’ for the Listener Control utility and so on).

After that, you need to open a new terminal window so that the revised .bashrc gets invoked, and you can then run SQL*Plus (and any other program) as normal... only this time, you'll find that once you've issued a few commands, you'll be able to hit the up-arrow key to retrieve them.It will be as if Microsoft had never gone away!

Meanwhile, you will find that rlwrap can be made even more usable , if such a thing were possible, by the judicious use of Ctrl+R. This let's you search through the command line history, instead of just having to up- and down-arrow through it sequentially. As you type part of a command, the utility finds commands which match what you type. Bliss!

I love it. I notice Tom Kyte loves it. Strong DBAs have been known to go weak at the knees when they see it for the first time, and some have even shed a tear. 'Nuff said: it rocks!! If only it (or something like it) was built into SQL*Plus in the first place (hint, hint)!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章