Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Console2 to run a Powershell in which I run plink.exe to connect to a Linux server. It works fine except that ps, top and other utilities in the shell only thinks the output window is 80 characters wide, while the window really is about 200 characters wide. How can I get them to detect the real console size?

share|improve this question
up vote 2 down vote accepted

plink is designed to be used as a transport for binary data. It does not provide any sort of terminal emulation – and neither does the Windows console. This means that the remote end simply cannot know your terminal size.

If you want a full-featured console-based SSH client, install Cygwin OpenSSH.

share|improve this answer
Hm, I don't understand that. In Console2.exe (the console) I'm running PowerShell.exe (the shell) running plink.exe (ssh transport) to connect to a server. Isn't that analoguous to gnome-terminal running bash running ssh? If it works on a Linux client, why not on a Windows one? – Björn Lindqvist Jan 9 '12 at 8:58
@BjörnLindqvist: It is somewhat analogous. The most important difference is that unlike GNOME Terminal, the Windows console does not process ANSI/VT220 escape sequences; instead, programs call special functions, somewhat like ioctls, on the console handle, to change text format or move cursor. When using Cygwin programs (such as Cygwin OpenSSH) the cygwin1 runtime performs this sequence -> API translation automatically; when using native Win32 programs (such as plink) this does not happen. – grawity Jan 9 '12 at 10:24
@BjörnLindqvist: Another difference is that the plink client, having been written with batch usage in mind, does not by default allocate a TTY on the server side, making it impossible for remote programs to find out the screen size. (Full-screen programs use special ioctl's on their output device if it is a tty; they cannot do so on simple pipes when there is no tty.) Even if you use plink -t forcing the TTY allocation, plink does not forward the actual console size -- it always sets a generic 80x25. On the other hand, OpenSSH has the same client for both batch and interactive usage. – grawity Jan 9 '12 at 10:28
@BjörnLindqvist: Side note: Console2.exe is not the actual console; it is only a thin GUI wrapper around a hidden Windows Console window, reading its screen buffer periodically; it cannot add new functionality to the console (such as ANSI/VT220 support), and it cannot modify the way plink and other console programs work. – grawity Jan 9 '12 at 10:32

I know the answer's been accepted, but let me just mention that PuTTY itself will bring up a proper terminal emulator without the issues OP had mentioned.

share|improve this answer

You can use putty to configure the Window size, which plink will then recognize. I have sent a patch to the PuTTY developers which makes plink use the current console width (at startup, it won't recognize resizing). Update: they have refused the patch, saying plink is not meant for interactive use. Update2: custom plink.

share|improve this answer

On the Linux side, what's your shell?

If it's bash (which I assume it is) you can tell bash to update it's idea of what the window size is


shopt -s checkwinsize

into your Linux $HOME/.bashrc. I'm not sure what the equivalent would be for zsh

share|improve this answer
FYI, checkwinsize merely causes $ROWS/$COLUMNS to be updated, and such full-screen utilities as top do not depend on these variables -- they query the tty device directly. – grawity Jan 5 '12 at 18:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .