Where Have You Been All My Life? Rlwrap

December 13, 2009

in sysadmin

Back in the days of yore (when sysadmins still had to bang two rocks together to do their job), we didn’t have command line history. No, we typed every command by hand. If we had to type the same 110-character command-line several times, we typed those 550 characters ourselves, mistakes and all, and by gum, we LIKED it!

And then shells became available with history functionality and, well, we kind of liked that too. And, um, then came along libraries like GNU readline that were written to provide even more pleasant, vizz-eee-ul history recall and editing to anything that presents a command line prompt, and well, ok, we REALLY that too. Because, quite frankly, typing long command line strings over and over again, sometimes because our typing skills aren’t always sharp, is a real drag.

But alas, not every program that provides a command-line prompt or handles interactive input provides this new-fangled user experience (I’m looking at you sqlplus, maybe if scott had a real tiger…). In the past, a sysadmin had to look admonishingly at one of these programs, perhaps working around the lack of interface using something like Expect.

Maybe I’m the last admin on the planet to hear about this idea, but it came as a pleasant surprise to find out that there are a number of programs out there whose whole purpose in life is to add the readline-yumminess to programs that don’t have it already. The first one I encountered was rlwrap by Hans Lub. Now you can type:

$ rlwrap sqlplus scott/tiger@oracle_instance

And you get a reasonable command-line environment even from within sqlplus.

I know I would have offered at least a vestigial body part several times in the past to have the “add readline to command X” super power several times during my career. (apparently this tip has been making people in the Oracle community happy for a while now).

The rlwrap README mentions two other similar packages: rlfe which even ships with the GNU readline distribution and cle. I note that cle hasn’t been touched for over ten years (the last release’s 10th birthday was just over a week ago). I can’t speak to how well rlfe works, but kudos to Lub for continuing to update the rlwrap package.

Hope this tip brings you a similar amount of joy.

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: