Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GETTING xterm title from tcsh

1 view
Skip to first unread message

Joshua M. Dobies

unread,
Dec 22, 1998, 3:00:00 AM12/22/98
to
I've recently learned that you can set the title of an xterm from tcsh.
Very cool.
echo "^[]2;<title>^G"
where ^[ = the Esc key,
^G = Ctrl-g.
note: you may have to type Ctrl-V first before typing Esc or Ctrl-g.

(source: "Using csh & tsch", Paul Dubois, O'Reilly and Associates
Inc.")
BUT....
I want to know if there's a way to GET the current title of an xterm
window so I can save it in the environment before setting it.
Thanks.

vcard.vcf

Casper H.S. Dik - Network Security Engineer

unread,
Dec 23, 1998, 3:00:00 AM12/23/98
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

"Joshua M. Dobies" <jdo...@us.oracle.com> writes:

>I want to know if there's a way to GET the current title of an xterm
>window so I can save it in the environment before setting it.
>Thanks.

There's no way to do so and I'm happy there isn't.

If there was such a way, I could construct a file that caused the following:


set window title to some unix command (rm -rf /)
get window title

oops.

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.

T.E.Dickey

unread,
Dec 23, 1998, 3:00:00 AM12/23/98
to
Casper H.S. Dik - Network Security Engineer <Caspe...@holland.sun.com> wrote:
>>I want to know if there's a way to GET the current title of an xterm
>>window so I can save it in the environment before setting it.
>>Thanks.

> There's no way to do so and I'm happy there isn't.

> If there was such a way, I could construct a file that caused the following:

> set window title to some unix command (rm -rf /)
> get window title

otoh, dtterm does allow this (that's the supported program, right?)

--
Thomas E. Dickey
dic...@clark.net
http://www.clark.net/pub/dickey

Casper H.S. Dik - Network Security Engineer

unread,
Dec 23, 1998, 3:00:00 AM12/23/98
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

"T.E.Dickey" <dic...@shell.clark.net> writes:

>Casper H.S. Dik - Network Security Engineer <Caspe...@holland.sun.com> wrote:
>>>I want to know if there's a way to GET the current title of an xterm
>>>window so I can save it in the environment before setting it.
>>>Thanks.

>> There's no way to do so and I'm happy there isn't.

>> If there was such a way, I could construct a file that caused the following:

>> set window title to some unix command (rm -rf /)
>> get window title

>otoh, dtterm does allow this (that's the supported program, right?)

Another reason to avoid dtterm :-)

It's interesting how security bugs get reinvented.

Programmable answerback sequences are a bad idea.

Kuntal M. Daftary

unread,
Dec 23, 1998, 3:00:00 AM12/23/98
to Casper H.S. Dik - Network Security Engineer, jdo...@us.oracle.com
On 23 Dec 1998, Casper H.S. Dik - Network Security Engineer wrote:

> "Joshua M. Dobies" <jdo...@us.oracle.com> writes:

> >I want to know if there's a way to GET the current title of an xterm
> >window so I can save it in the environment before setting it.

> There's no way to do so and I'm happy there isn't.

not true.

> If there was such a way, I could construct a file that caused the following:
> set window title to some unix command (rm -rf /)
> get window title

> oops.

well, no. getting window title does not necessarily mean executing it.

here is what i found (and it works!)

method 1: a ksh script
#!/bin/ksh
# Echo the current X term title bar to standard output.
# Written by Icarus Sparry <ica...@bath.ac.uk> 11 Apr 1997
exec </dev/tty
old=$(stty -g)
stty raw -echo min 0 time ${1-10}
print "\033[21t\c" > /dev/tty
IFS='' read -r a
stty $old
b=${a#???}
print -R "${b%??}"

method 2: smaller but depends on WINDOWID environ variable being set (which
tcsh does, well at least mine does).

# by Hemant Shah <sh...@typhoon.xnet.com>
% xprop -id $WINDOWID | grep WM_NAME | sed 's/.*"\([^"]*\)"$/\1/'

i got the above from Tom Dickey's Page:
http://www.clark.net/pub/dickey/xterm/xterm.faq.html#how2_title

(unfortunately, no part of my reply is original :-))

Kuntal Daftary

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.2

mQBtAzaArtcAAAEDAKUaWwRtqx46wFTLHDpGcILS7ehqZiIH+x5DWmgNmKTR5P0N
Sr12QyTcnBEu9+lf1i9vWJi8rjPpsZhoUfHrGoy51KDxdT+B7mzjFoCSr+YLdboi
peswJknZk/G3jZmsgQAFEbQiS3VudGFsIERhZnRhcnkgPGRhZnRhcnlAY2lzY28u
Y29tPokAdQMFEDaArxbZk/G3jZmsgQEB4tUC/3vcqFPQQabRcoxm3gzxFkPmIKJU
+0YgV+1UwaqFzrKmpFZgP7+iLH2OhTC778NtZ7D1mRqt7q4AE0bPAijXyw04H8iA
nI/SNyvpZOL2LnzOVCuMoy/31loZ/53XqhgOiQ==
=6rgJ
-----END PGP PUBLIC KEY BLOCK-----

Barry Margolin

unread,
Dec 24, 1998, 3:00:00 AM12/24/98
to
In article <Pine.GSO.3.96.981223...@daftary-ultra.cisco.com>,

Kuntal M. Daftary <daf...@cisco.com> wrote:
> well, no. getting window title does not necessarily mean executing it.

I posted something similar, but cancelled it within a minute when I
realized I was wrong.

If you "cat" a file that contains the control sequence that causes xterm to
insert the title into the input stream, then when cat exits the shell will
read that input. This is similar to the ancient problem of terminals that
have programmable function keys as well as control sequences to get what's
stored in them.

--
Barry Margolin, bar...@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.

Casper H.S. Dik - Network Security Engineer

unread,
Dec 24, 1998, 3:00:00 AM12/24/98
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

"Kuntal M. Daftary" <daf...@cisco.com> writes:

>On 23 Dec 1998, Casper H.S. Dik - Network Security Engineer wrote:

>> "Joshua M. Dobies" <jdo...@us.oracle.com> writes:

>> >I want to know if there's a way to GET the current title of an xterm
>> >window so I can save it in the environment before setting it.

>> There's no way to do so and I'm happy there isn't.

> not true.

Well, it doesn't work on mine.

Which OS/version of xterm are you using? (I just checked the R6.4 xterm
sources, doesn't seem to be any evidence for a ESC[21t command)

So it appears to be a non-standard xterm feature.

> well, no. getting window title does not necessarily mean executing it.

No, but it was reasy to stuff "; rm -rf /;" in the input buffer.

>here is what i found (and it works!)

Not on any xterm I'm familiar with; which OS do you use?

Ah, wait, the URL says:

This works for XFree86 xterm and dtterm, but not for other variations:

>method 2: smaller but depends on WINDOWID environ variable being set (which
>tcsh does, well at least mine does).

Tcsh doesn't set it, xterm does.

># by Hemant Shah <sh...@typhoon.xnet.com>
>% xprop -id $WINDOWID | grep WM_NAME | sed 's/.*"\([^"]*\)"$/\1/'

I remember seeing this one before; it's a safe way of getting the title.

(There's also WM_ICON_NAME)

>i got the above from Tom Dickey's Page:


and the page explains that xterm doesnt' allow you to send teh title to
the input buffer but dtterm XFree86 xterm both do.

It's a dangerous feature that should be removed.

Casper H.S. Dik - Network Security Engineer

unread,
Dec 24, 1998, 3:00:00 AM12/24/98
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

Barry Margolin <bar...@bbnplanet.com> writes:

>In article <Pine.GSO.3.96.981223...@daftary-ultra.cisco.com>,
>Kuntal M. Daftary <daf...@cisco.com> wrote:

>> well, no. getting window title does not necessarily mean executing it.

>I posted something similar, but cancelled it within a minute when I
>realized I was wrong.

>If you "cat" a file that contains the control sequence that causes xterm to
>insert the title into the input stream, then when cat exits the shell will
>read that input. This is similar to the ancient problem of terminals that
>have programmable function keys as well as control sequences to get what's
>stored in them.

Try catting teh following file (after uudecoding it)

It's

ESC]0;;ls -l;^G
ESC[21t

catthis

T.E.Dickey

unread,
Dec 24, 1998, 3:00:00 AM12/24/98
to
Casper H.S. Dik - Network Security Engineer <Caspe...@holland.sun.com> wrote:
> It's a dangerous feature that should be removed.

> Casper


> --
> Expressed in this posting are my opinions. They are in no way related

as you say: _your_ opinion (you ought to follow up by persuading Sun to
drop dtterm then ;-)

Casper H.S. Dik - Network Security Engineer

unread,
Dec 24, 1998, 3:00:00 AM12/24/98
to
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]

"T.E.Dickey" <dic...@shell.clark.net> writes:

>Casper H.S. Dik - Network Security Engineer <Caspe...@holland.sun.com> wrote:
>> It's a dangerous feature that should be removed.

>> Casper
>> --
>> Expressed in this posting are my opinions. They are in no way related

>as you say: _your_ opinion (you ought to follow up by persuading Sun to
>drop dtterm then ;-)


Not dropping dtterm, but fixing it to make the "answerback" feature
optional.

Casper
--
Expressed in this posting are my opinions. They are in no way related

T.E.Dickey

unread,
Dec 24, 1998, 3:00:00 AM12/24/98
to
Casper H.S. Dik - Network Security Engineer <Caspe...@holland.sun.com> wrote:
>>as you say: _your_ opinion (you ought to follow up by persuading Sun to
>>drop dtterm then ;-)


> Not dropping dtterm, but fixing it to make the "answerback" feature
> optional.

well, keep us posted on your progress.

0 new messages