Does this site look plain?

This site uses advanced css techniques

My main desktop workstation runs Window NT, but most of my real work is done on UNIX systems via telnet. The one I use (SecureCRT, from VanDyke Software) has an excellent VT220 emulator, and I often resize the window to see more or less of a particular screen. The telnet protocol has a way to pass this resize information directly to the program on the other end, but not all systems/programs can or do use it correctly. This means constant manually setting of the screen size:

$ export LINES=27 COLUMNS=132

This gets old pretty fast, so I wrote a program that will do this for me. Rather than rely on aspects of the telnet protocol (which may or not be available), it simply asks the emulator directly. The "wsize" program moves the cursor to as far as it can in the lower right, then queries the current cursor location. The emulator responds, and from here we know the screen size.

Once the C program is compiled, install it to a public place (say, /usr/local/bin) and try it with a simple:

$ wsize

It will respond with export LINES=27 COLUMNS=132. To have the shell actually use the variable, the output must be "eval"-ed, and this is done with:

$ eval `wsize`

"eval" tells the shell to interpret the output of the program and run the commands directly: this sets the $LINES and $COLUMNS environment variables in the current shell, and they take effect immediately.

To make this a bit more convenient, I define an alias in the /etc/profile that does this for me:

alias wsize='eval `/usr/local/bin/wsize`'

Be sure to get the quotes right!

When you type wsize, it's having an escape-code conversation with the emulator, and anything you type could interfere with its ability to receive the proper response. The program knows that if it doesn't get a valid reply in a short time (one second) it won't be forthcoming, so it abandons the effort and resets the terminal the way it was. So far I've never had wsize mess up my session, but I suppose it's possible.

Do I Need This Program?

Maybe. If you are telnetting directly to a modern UNIX machine (such as Linux), this program is probably not necessary, but older systems and those reached via multiple "hops" or via non-telnet protocols won't be able to get the window size right without help. To find out, login to the system of choice with a "standard" screen size. Increase the window size and launch vi. If it takes up the bottom line, your system probably doesn't need this program.

Telnet normally passes the window size parameters via an out-of-band link, and when the telnet daemon on the other end receives it, it generates a SIGWINCH (window change) signal to the process attached to your login shell. This program can use this signal to set the proper parameters. vi on a Linux machine will automatically redraw itself when a window is resized because the whole chain supports this.

If there is more than one "hop" involved, this window information probably won't be passed to the final system. Using telnet to a gateway machine and then rlogin to another machine (or using the rlogin protocol on the emulator client directly) will make it impossible for the window size information to be passed to the ultimate system. For this reason I never use the rlogin protocol in the CRT client even though they support it well. Rlogin simply has no out-of-band channel for this window size information.

Getting the program

The C language source code can be found here. This code is in the public domain and has no restrictions whatsoever. I'd like to know of bugs or porting problems you find, but none of this is with any warranty. How could it be any other way?

If you find that this program works with other brands of emulators, please do let me know so I can update this page.

About VanDyke Software "CRT" and "SecureCRT"

I have been using the program "CRT" from VanDyke Software ( ) for a long time, and it's a fantastic emulator. The telnet that comes with Windows is so shoddy that it would not take much of an effort to be "better", but it's clear that VanDyke are trying for a quality product even if their "competition" is so lame.

Recently I installed the secure shell server on customer machines and am using VanDyke's Secure CRT program, and it's just as solid and I wouldn't use another program even if it were free. Prices (as of March 2000) for single copies were about $35 for CRT and about $99 for Secure CRT. They have a 30-day trial period on both, plus a few other products that are probably just as good as CRT. Their support (technical and sales) via email has been outstanding, and they were very accommodating on an unusual licensing request. There is just nothing not to like about these people.

Disclaimer: I'm just a very happy VanDyke customer, not a reseller.