Telnet server in python that changes the title of the PuTTY window

-1

Does anyone have any Telnet server scripts that change the title of the PuTTY window from who they connect to?

    
asked by anonymous 20.08.2018 / 21:19

1 answer

1

Changing the title of the "connection window" is not part of Telnet or SSH protocols, nor does it make sense to do so - but PuTTY emulates the behavior of VT100 terminals - and for these, a protocol is defined above the content for window title change.

The ANSI escape sequence "OSC 0; ST" can change the title of the window that has connected to the server - this sequence only has to be printed on the connected terminal. If the connection is to have a login to the operating system's shell prompt, one way to do this is to change the $ PS1 environment variable, and include that string inside the prompt itself.

Not knowing more about your goals with the telnet connection, and what it has to do with Python, it's hard to be more specific.

If your Telnet connection is printing the output of the Python program, the above sequence can be displayed with:

print("\x1b]0;{}\x1b\".format("Seu titulo aqui"))

(In Python, '\ x1b' is the ESC character representation, the sequence 'ESC +] "is the command" OSC "-" Operating System Command ", and the command" 0; "the command to change The string "ESC \" is the same as "ST" ("STRING TERMINATOR"), which ends the command.) "{}" is used by Python's own .format method to replace the title desired, leaving well separated the content you want to put in the title of the commands required for it.

The complete documentation of the ANSI control characters is here:

link

    
20.08.2018 / 23:09