I'm using Putty on my Windows PC. I noticed my log files created using Putty's default "Printable output" logging will log all key press, even those I have deleted.

For example, if I want to type abcd, but I mis-typed as abvd, and I press Backspace twice to delete vd, and re-type cd, the log file will output as abvdcd. How can I correct the log file to only display the inputs after I hit the Enter key so it correctly shows abcd in the log file?

Note: I can't install any external software on my Windows PC so hopefully there is a way to solve this native on Windows. I do not have any programming background either.

1 Answer 1


I don't think you should see abvdcd -- on my testing I get abvd cd.

Assuming SSH (which is what most people use Putty for) you can't. It sends each typed character to the host immediately, and the host does the line-editing. For this example:

  • you type a b c d. Putty sends these characters to the host, which puts them in its buffer and echoes them back to Putty which shows them on the screen and logs them.

  • you type two backspaces. Putty sends these to the host, which deletes two chars from the buffer; for each one it (conventionally?) echoes backspace space backspace, and when Putty puts this sequence to its screen it has the net effect of visually erasing the two characters and leaving the cursor where the first used to be, i.e. after 'ab'. Putty also logs as configured; if you have 'all output' and look at the file with a tool that displays invisible control characters you should see the whole sequence, but 'printable output' only logs the space.

    It is possible you might be using a host that uses some other method of displaying the effect of backspace, like backspace erase-line or backspace erase-chars(1).

  • You type c d; Putty sends them to the host which adds them to its buffer and echoes them to Putty which displays and logs them.

  • You type return and Putty sends it to the host, which echoes CR and LF which Putty displays and logs. The host also processes the input buffer as it now stands ('abcd') which probably results in some output.

As you can see, all these characters (a b v d [BS] SP [BS] [BS] SP [BS] c d CR LF) actually came from the host, and Putty has no way to distinguish that some should be logged and some not. If you use line-kill on Unix (conventionally ^U) at least on my CentOS it echoes (and logs) multiple backspaces as needed then erase-rest-of-line (which is ESCape [ K, where the sequence ESC [ is also called CSI Command Sequence Introducer).

If you log with 'all' and have Unix or Unix-like utilities available, you could run the file through col -b plus something like sed 's/\x1b\[[0-9]*[A-Z]//' if necessary to get the 'final displayed result'. This would also fix any (other) host output that attempts to use overstriking as some things like man and nroff like to do, and decades ago on printing terminals often worked well.

If you are using Telnet, which Putty also supports but most hosts no longer do since it's insecure, that protocol by default behaves the same way, but it does have an option for the line-editing to be done at the client before sending. I can't tell if Putty supports this option, and which if any hosts still do -- IME it used to be popular mostly on 'big iron' mainframes like IBM Univac GE that almost nobody uses directly today.

  • Hi Dave. Thanks for the reply. I guess SecureCRT is slightly more intuitive with the logging.
    – Guest
    Oct 29, 2018 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.