1

I was randomly experimenting and I found that running cat /etc/localtime on PuTTY and on xterm have different effects.

Example:

root@webtest:~# cat /etc/localtime
TZif2

     ▒
      ▒▒Kmp▒▒ǀ▒▒▒p▒Ƀprp▒▒▒▒_Tp▒▒▒p▒A▒p▒nop▒#
▒O▒▒▒p▒▒▒ɧ▒#▒Op▒▒▒k▒p"p▒r▒p▒Pp▒2Lp▒▒p▒▒▒p▒▒p▒ȷ𽸨▒_p▒▒▒▒▒▒▒▒xl▒▒h]▒▒XN▒▒?p▒80▒▒:▒▒▒X▒p▒▒▒p▒/p▒▒ p▒▒b▒˵R▒▒▒▒̀K▒▒ܢ▒͕4▒▒▒K`▒r▒▒▒ſp▒u▒Ϭg▒▒R▒▒Х▒p▒T▒▒ьI▒▒2f▒҅▒p▒Y▒▒▒I▒▒▒9▒ ▒)▒ ▒▒ ▒      PuTTYPuTTYPuTTY▒ ▒▒ ▒▒ ܹY ݲ▒▒ޢu▒ߒf▒▒W▒▒rH▒▒b9▒▒R*▒▒B▒2
▒▒!▒▒
      ▒▒
         ▒▒▒ ▒▒▒ ▒▒▒ ▒▒ ▒▒   ▒z▒ ▒j▒ ▒c▒▒▒S▒▒▒C▒▒▒3▒▒▒#s▒▒d▒▒U▒▒▒F▒
▒*
▒7▒t(▒d▒T▒C▒3▒#▒ܐ͐▒㽠Ӡ▒Ñ▒▒▒▒▒▒▒▒|▒ lr!\c"LT#<E$,6%'&
'C▒'▒4▒(▒%▒)▒▒*▒▒+▒▒,▒▒-▒ڐ.▒ː/t▒▒0d▒▒1]▒2r▒3=▒4R▒5▒62x68▒8▒a9▒v▒:▒C;▒X▒<▒_▒=▒:▒>▒A▒?▒▒@f#▒A▒9BF▒Cd
                  %▒EC▒FɐG#▒G▒▒I▒I▒▒J▒K▒▒L̿▒M▒▒N▒▒▒OnnP▒▒▒QW▒▒Rle▒S7l▒TLG▒UN▒V,)▒V▒0▒XFX▒▒Y▒(Z▒▒[▒
\▒]▒▒▒_▒▒`_▒a}▒b?▒c]̐d▒e=▒▒▒▒g▒▒g藐h▒r▒i▒y▒j▒T▒k▒[▒l▒qm▒=▒n▒Soh▒p▒5qQ<rfs1tE▒uv/▒v▒▒x▒x▒▒y▒ِz▒▒{λ▒|▒�}▒▒▒~y▒▒     PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY









































 ▒▒c    LMTWESTWETWEMTCETCESTTZif2

                                  ▒
                                   ▒▒▒▒▒▒▒▒▒▒Kmp▒▒▒▒▒▒ǀ▒▒▒▒▒▒▒p▒▒▒▒▒Ƀp▒▒▒▒rp▒▒▒▒▒▒▒▒▒▒▒▒▒_Tp▒▒▒▒▒▒▒p▒▒▒▒▒A▒p▒▒▒▒▒nop▒▒▒▒▒#
▒▒▒▒▒▒O▒▒▒▒▒▒▒▒p▒▒▒▒▒▒▒▒▒▒▒▒ɧ▒▒▒▒▒▒▒#▒▒▒▒▒▒▒Op▒▒▒▒▒▒▒▒▒▒▒▒▒k▒▒▒▒▒▒p"p▒▒▒▒▒r▒p▒▒▒▒▒Pp▒▒▒▒▒2Lp▒▒▒▒▒▒p▒▒▒▒▒▒▒p▒▒▒▒▒▒p▒▒▒▒▒ȷ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒_p▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒xl▒▒▒▒▒▒h]▒▒▒▒▒▒XN▒▒▒▒▒▒?p▒▒▒▒▒80▒▒▒▒▒▒:▒▒▒▒▒▒▒X▒p▒▒▒▒▒▒▒p▒▒▒▒▒/p▒▒▒▒▒▒ p▒▒▒▒▒▒b▒▒▒▒▒˵R▒▒▒▒▒▒▒▒▒▒▒▒̀K▒▒▒▒▒▒ܢ▒▒▒▒▒͕4▒▒▒▒▒▒▒K`▒▒▒▒▒r▒▒▒▒▒▒▒ſp▒▒▒▒▒u▒▒▒▒▒Ϭg▒▒▒▒▒▒R▒▒▒▒▒▒Х▒p▒▒▒▒▒T▒▒▒▒▒▒ьI▒▒▒▒▒▒2f▒▒▒▒▒҅▒p▒▒▒▒▒Y▒▒▒▒▒▒▒I▒▒▒▒▒▒▒9▒ ▒▒▒▒▒)▒ ▒▒▒▒▒▒ ▒▒▒▒▒   ▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒ܹY ▒▒▒▒ݲ▒▒▒▒▒▒ޢu▒▒▒▒▒ߒf▒▒▒▒▒▒W▒▒▒▒▒▒rH▒▒▒▒▒▒b9▒▒▒▒▒▒R*▒▒▒▒▒▒B▒▒▒▒▒2
▒▒▒▒▒▒!▒▒▒▒▒▒▒▒▒▒
                  ▒▒▒▒▒▒
                         ▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒ ▒▒▒▒ ▒▒▒▒▒z▒ ▒▒▒▒▒j▒ ▒▒▒▒▒c▒▒▒▒▒▒▒S▒▒▒▒▒▒▒C▒▒▒▒▒▒▒3▒▒▒▒▒▒▒#s▒▒▒▒▒▒d▒▒▒▒▒▒U▒▒▒▒▒▒▒F▒
▒*
▒7▒t(▒d▒T▒C▒3▒#▒ܐ͐▒㽠Ӡ▒Ñ▒▒▒▒▒▒▒▒|▒ lr!\c"LT#<E$,6%'&
'C▒'▒4▒(▒%▒)▒▒*▒▒+▒▒,▒▒-▒ڐ.▒ː/t▒▒0d▒▒1]▒2r▒3=▒4R▒5▒62x68▒8▒a9▒v▒:▒C;▒X▒<▒_▒=▒:▒>▒A▒?▒▒@f#▒A▒9BF▒Cd
                  %▒EC▒FɐG#▒G▒▒I▒I▒▒J▒K▒▒L̿▒M▒▒N▒▒▒OnnP▒▒▒QW▒▒Rle▒S7l▒TLG▒UN▒V,)▒V▒0▒XFX▒▒Y▒(Z▒▒[▒
\▒]▒▒▒_▒▒`_▒a}▒b?▒c]̐d▒e=▒▒▒▒g▒▒g藐h▒r▒i▒y▒j▒T▒k▒[▒l▒qm▒=▒n▒Soh▒p▒5qQ<rfs1tE▒uv/▒v▒▒x▒x▒▒y▒ِz▒▒{λ▒|▒�}▒▒▒~y▒▒









































 ▒▒c    LMTWESTWETWEMTCETCEST
WET0WEST,M3.5.0/1,M10.5.0
PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYroot@webtest:~# PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY

But when I run on xterm, it gives me this:

root@webtest:~# cat /etc/localtime
TZif2

     Ý
      æmpÇíppêp¢AÙp£nop¤#
                         ð¥O¢ðªïpªôð­É§ð®§#ð¯ Op°ð±kð²p"p³rp´Pp·2Lp¸Èp¸ÿ¹p¹ïªp¼È·ð½¸¨ð¾ðÀððÁxlðÂh]ðÃXNðÄ?pÅ80ðÆ:ðÇX¬pÇÙßpÉ/pÉñ pÊâbð˵RðËì£àÌKàÌÜ¢ðÍ4ðÍÃK`Îr¢àÎÅ¿pÏuðϬgàÐR
           àÐ¥¡pÑTøðÑIàÒ2fàÒ
pÓYÄðÔIµðÕ9Ñ Ö) ׳ Ø^[[?64;1;2;6;6;9;15;18;21;22c      ¤ Øù Ùé ܹY ݲ
                                                                       Þ¢u ßf àW árH âb9 ãR* äB2
                 æ!ý ç
                       èû
                          éêü êÚí ëÊÞ ìºÏ íªÀ î± ï¢ ðz ñj
                                                          òc¯ óS  ôC õ3 ö#s ÷d øU øóF 
      «*

7t(dT3ú㽠Ӡý¬® lr!\c"LT#<E$,6%'&
                                  'CÚ
                                     Ë5A
                                        9BF
                                           %çN¬¡leÎ`_Õa}êe=®=5qQ<rfs1tEùuv/Âæÿÿÿ

Why is PuTTY putting PuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTYPuTTY on the prompt?


Edit: This question isn't a duplicate of Why using cat on binary files messed up the terminal and how?

The linked question asks why the ouput is different, even when redirecting the output to a file.

My question is asking why it is showing PuTTY in the prompt (note: on the prompt, where we type the commands), on PuTTY.

I'm really sorry, but I'm not being able to express my doubt any better.

1
  • 1
    It's not a duplicate (of the given question). – Thomas Dickey Dec 2 '16 at 16:17
7

It's an FAQ (for PuTTY):

A.7.12 When I cat a binary file, I get ‘PuTTYPuTTYPuTTY’ on my command line.

Don't do that, then.

This is designed behaviour; when PuTTY receives the character Control-E from the remote server, it interprets it as a request to identify itself, and so it sends back the string ‘PuTTY’ as if that string had been entered at the keyboard. Control-E should only be sent by programs that are prepared to deal with the response. Writing a binary file to your terminal is likely to output many Control-E characters, and cause this behaviour. Don't do it. It's a bad plan.

To mitigate the effects, you could configure the answerback string to be empty (see section 4.3.7); but writing binary files to your terminal is likely to cause various other unpleasant behaviour, so this is only a small remedy.

PuTTY's developers started off by copying things, and sometimes they forget the reason. The answerback sequence (for a while) in xterm would echo "xterm". But that went away in 1999:

change default answerback response to an empty string.

Notwithstanding that, you'll still find people saying that xterm does this (by default).

When a terminal sends an answerback response, the result is just as if you had typed that information. Your shell (or other program) will echo the characters.

1
  • This answers 90% of the question. But still: Why does it go to the prompt? After running the command and hitting Enter, it will run PuTTYPuTTY[...]. Is there any key sequence that makes it go to the prompt? – Ismael Miguel Dec 2 '16 at 16:10
2

/etc/localtime is a symbolic link to a binary file, not a text file. Dumping the contents of a binary file to a terminal can have interesting and unexpected results, particularly if some of the binary data happen to match terminal control codes. PuTTY may have a control code to output its name, which xterm does not or if it does, it parses differently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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