Remotely setting putty window title


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remotely setting putty window title
# 1  
Old 01-27-2012
Remotely setting putty window title

I have successfully used a script to modify putty's window title for many years. It has worked great in a Solaris 10 environment, using, sh, bash and tcsh. But I've never been able to get it to work in linux Smilie

The script relies on sending escape sequences via gnu echo. The version of echo on both solaris and linux is exactly the same:

/bin/echo --version
echo (GNU coreutils) 5.97

The terminal client is putty 0.62, issued from a PC running Win7. The connection is via an ssh session.

For example, this works:

% /bin/echo "\033]0; JUST TESTING \007\c"

When it succeeds, nothing is echoed in the CLI session, and instead putty's window title changes to "JUST TESTING".

When if fails, it does nothing to putty's title, and instead echoes out this to the CLI session:

% /bin/echo "\033]0; JUST TESTING \007\c"
\033]0; JUST TESTING \007\c

I've tried, without success, all of these combinations (and more):

/bin/echo \\033]0\\; JUST TESTING \\007\\c
/bin/echo \\033]0\\; JUST_TESTING \\007\\c
/bin/echo \\033]0\\;JUST_TESTING\\007\\c
/bin/echo \\033]0\;JUST_TESTING\\007\\c
/bin/echo \033]0\;JUST_TESTING\\007\\c
/bin/echo "\033]0; JUST TESTING \007\c"
/bin/echo '\033]0; JUST TESTING \007\c'
/bin/echo \033]0\;JUST_TESTING\007\c
/bin/echo \033\]0\;JUST_TESTING\007\c
/bin/echo \\033]0\\;JUST_TESTING\\007\\c
/bin/echo \\\033]0\\\;JUST_TESTING\\\007\\\c

FWIW It works on the solaris system even if I first ssh to the linux system and then to the solaris system, so the packets are routed through the linux system on its way back to my PC.

Any ideas on how I can get this working would be greatly appreciated!

Thanks,
-Bob
Andover, MA US
# 2  
Old 01-27-2012
echo's behavior with embedded escape sequences is inconsistent. Some don't expand escape sequences at all, some only do so when given -e, some do all the time. It gets worse -- since it's often a shell builtin, it's behavior may be different depending on the shell you use, even on the same system!

Linux's manual page for echo would have told you about the -e flag.

You should be using printf, which is nearly the same everywhere, and always handles escapes. Just add a \n onto the end of your strings and only give it one string. printf "\033]0; JUST TESTING \007\c\n"
# 3  
Old 01-27-2012
Thanks for the tip on printf.

BTW I explicitly invoked /bin/echo so as to avoid any shell built-in echo. Furthermore, /bin/echo is the same version on both systems (i.e., gnu 5.97)

Also, I did check the manpage for echo, found the '-e' option and tried it. But it made no difference. I should have included that in the list of variations I tried!

Anyway, printf failed for me on the linux system, like this:

% printf "\033]0; JUST TESTING \007\c\n"
\c

(but it worked fine on the solaris system)

However, there is hope .. the printf on my solaris is version 8.10 from gnu coreutils, whereas it is an unknown version from the year 2006 on the linux system. I will upgrade printf and try it out.

thanks!
# 4  
Old 01-27-2012
Translate "\c" into its octal equivalent and it'll work fine on printfs from 2012, 2006, or 1996...
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 01-27-2012
Using "\003" instead of "\c" makes it work like a charm .. even with the older printf.

Thanks for the help!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Getting command output to putty window title.

Hi, Last 2 weeks I have searched many forums and i haven't found the answer for the question: How to get all command output to Putty title? Needed it for other programs to know when some jobs on a server is done and is it done right or wrong. Plink stdout and stdin wasn't working, i used many... (1 Reply)
Discussion started by: domagaj
1 Replies

2. Shell Programming and Scripting

Help with putty window setting

hi friends, This is not a shell scripting related doubt, but still posting so that you can answer it ;) or redirect to correct place in this website. Many a times i have to open multiple putty sessions by duplicating a session and want to rename their tabs. For this activity i have to right... (4 Replies)
Discussion started by: kunwar
4 Replies

3. UNIX for Dummies Questions & Answers

Change putty title name

Hello all, I have a not so unix question for you guys(or maybe it is). I use PUTTY to login to serverA (my putty title shows as serverA.domainname.com) Now from ServerA i do ssh user@ServerB (i have ssh public private key setup)... now my question is when i do ssh and logon to... (20 Replies)
Discussion started by: abdul.irfan2
20 Replies

4. Linux

how to insert a title into a window in kshell

hi all, i am using a Ubuntu work station. i have following piece of code that works ok. But i cant figure out a way to insert a string call $Name into the title of the window i am opening. As you can see, i tried two different ways without a success. Can someone please help me out here? :( ... (3 Replies)
Discussion started by: usustarr
3 Replies

5. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: NateTut
2 Replies

6. Linux

execute a program remotely using putty

hi all. I have a small program on a debian server which i need to execute remotely from a windows machine using putty. when i use putty to execute the program it starts running , but when i close the session the program stops running on the debian server as well. Can anyone guide me how... (4 Replies)
Discussion started by: coolatt
4 Replies

7. UNIX for Advanced & Expert Users

PuTTY TITLE

Is it possible to set the PuTTY title to show the current hostname of the terminal opened? I meant to say I would be rlogin between servers, that should be updated in PuTTTY title ? :confused: (4 Replies)
Discussion started by: ./hari.sh
4 Replies

8. UNIX for Advanced & Expert Users

putty title window?

I have implemented the solution from mschwage located in post https://www.unix.com/unix-advanced-expert-users/35784-change-putty-title-window.html; ie wt () { echo -n "^2;${@}^G" } This method is awesome!!!! The reason I am sending you this message is to get your assistance with... (3 Replies)
Discussion started by: lwif
3 Replies

9. UNIX for Advanced & Expert Users

Change putty title window?

Is it possible to change the putty window title from a Unix command line? (12 Replies)
Discussion started by: akbar
12 Replies

10. UNIX for Dummies Questions & Answers

window title..?

how to echo some text onto the window title bar...in exceed client...so that we can know where we are in..in multiple hostnames kinda..thing.. any advice.. (1 Reply)
Discussion started by: tintedwindow
1 Replies
Login or Register to Ask a Question