Have you ever heard about rlwrap utility which brings the power to sqlplus or telnet or other command line utility?

Have you ever frustrated because you navigating through an expression with the arrow keys in command line utility and you get just something like this:

I try^[[Dto navigate^[[A^[[C somewhere^[[C^[[B in this text ^[[A^[[C^[[D^[[B.

If your answer yes, and you use application like nc (netcat), sqlplus, rman (from ORACLE), telnet, nslookup, nsupdate (http://en.wikipedia.org/wiki/Nsupdate), etc.  Many command-line-oriented applications don’t provide features like history, completion or line-editing.

Your friend is: rlwrap wraps readline (which is the library behind those features in bash and many other applications) around any line-oriented command. So you can take advantage of history, completion and editing facilities, even with applications that don’t provide them. The rlwrap is the kind of tool that, once discovered, makes you wonder how you could have lived without it.

For example, telnet or netcat don’t have editing facilities, neither history. I am Oracle DBA, and I will not surprise anybody if I say the sqlplus and rman also don’t have this options. Because maybe this utilities was borned the same time 🙂 So, with rlwrap, system/DB administrators or just a poor UNIX user will then be able to use those tools more efficiently.

Do you want to try it? Ok. The first thing to do is install rlwrap . We can do it from the source file from rlwrap-0.37.tar.gz. You can find rlwrap’s homepage at http://utopia.knoware.nl/~hlub/uck/rlwrap/

 (if you don’t have root access, you still able to install it locally in your $HOME)


# Tar-zxvf rlwrap *. Tar.gz

# cd rlwrap *

#. / configure          (won’t be surprise rlwrap request readline package)

# make

# make install


Or if your distribution repository contain the package, you are able to install with package managers like apt-get, yum, rpm … etc


# Apt-get install rlwrap


# rpm-ivh rlwrap-0.37 […]. rpm

(Note: the package name. Rpm depend on your system and architecture and you can find in rpm.pbone.net )


The next step is to define a couple of aliases that allow us to run sqlplus with the envelope of rlwrap . To do this, edit the file . bash_profile (or .bashrc) of user oracle and add the following lines:

alias sqlplus=’rlwrap -b “” -f $HOME/sql.dict sqlplus’

alias rman=’rlwrap -b “” -f $HOME/sql.dict rman’


File $HOME/sql.dict can contain a words for which you want to use ‘word completion’ feature. For example: select, v$session, configure, count(*). After that, while starting to type in slplus ‘co’ and pressing <Tab> we immediately get ‘count(*)’.


Option -b (or –break-chars) defines which characters are treated as word delimiters in file sql.dict. By default delimiters are: (){}[].,+-=&^%$#@\;|’ We don’t need such a big set (especially we don’t need ‘$’ as word delimiter), so we just specify an empty set. In such case only \r,\n and space will be treated as delimiters.

Of course, not only for sqlplus useful rlwrap, but also with any other command that can be benefit from this utility. At this point, mention that rlwrap is no Oracle utility anyway J.

By default, history is saved in a specific file for each program: your history will be kept even after exiting the program, and will not conflict with other apps. Just as readline, you can customize rlwrap with ~/.inputrc file. You can also define, for each application, a list of keywords. rlwrap will then perform completion on those words.


Voila our old dog sqlplus has just learned some new tricks. Happy editing in sqlplus! 

Author: gyzszabo

IT Architect ...

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s