How do I Get the Title of My Putty Window (Emulating an XTerm)

I have a Perl script that changes the terminal window title and I would like to reset it to the original value when I am done. We are using Putty which emulates xterm. We are not running X-Windows so I can't use something like xprop (can I?). I'm using XTerm control codes to change the title and I have found a code that returns the window title ESC[21t; It seems to work except it doesn't go to STDOUT or STDERR. I can see the title, but I need to capture it

Putty has an option: "Response to remote title query (SECURITY)" I would like to know how to make such a query. I understand the security implications, but this is behind a firewall and Putty will not be used on sites in the wild.

At first glance I thought this would be easy, but tratting the output of any command expressing this code to the XTERM window successfully in 'interesting'. It is far easier to record environment variables and use them to SET the title, I have not been able to capture it yet.

Have you searched for the trick using search engines?

It should be a shell/xterm trick, not specific to putty.

I found the XTerm escape sequence but Putty doesn't put it in STDOUT or STDERR so I can't capture it.:cool: