Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > General

Reply
 
Thread Tools Display Modes
  #1  
Old 04-19-2011, 04:45 AM
mdelor mdelor is offline
Registered User
 
Join Date: Apr 2011
Posts: 5
Question Prompt in the tab title or in the window title?

Hello,
Is there a way to dynamically have the prompt of the session on the tab or window title?
I've tried with %h or %s on the setting of the session but it doesn't work (it isn't dynamic)

Thanks in advance.

Marc
Reply With Quote
  #2  
Old 04-19-2011, 07:46 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Marc,

Thanks for the question. Would you be able to provide more information about what it is you are actually attempting to accomplish?

What part of the tab title do you want to be dynamic?

As a note, the hostname for a session and the session name will not change. These are static elements.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 04-19-2011, 10:17 AM
MrC MrC is offline
Registered User
 
Join Date: Mar 2004
Posts: 216
Quote:
Originally Posted by mdelor
Hello,
Is there a way to dynamically have the prompt of the session on the tab or window title?
See:
http://forums.vandyke.com/showthread...highlight=bash
Reply With Quote
  #4  
Old 04-19-2011, 11:04 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Thanks for the information MrC.

Marc, as is explained in the many threads on this forum, the tab title can be changed by the shell. It is important to note that a session cannot have Ignore window title change requests enabled. This option is located in the Terminal / Emulation / Advanced category of the Session Options dialog.

If you are looking for a simple example that is not discussed in the thread that MrC pointed out, or other threads that discuss this topic, please post what you specifically want, and I should be able to post an example to help accomplish your goal if you are using BASH.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #5  
Old 04-19-2011, 12:05 PM
mdelor mdelor is offline
Registered User
 
Join Date: Apr 2011
Posts: 5
First of all, many thanks for all your quick replies.
Sorry, perhaps I didn't give all the details, so here there are my exact way to work :
- I log on on a frontdoor, so my prompt is like fd1.domain.com#

And then I can have more than 10 active sessions :
** I log on an a server 1, so my prompt is like cray1.domain.com#(shell = bash) => I'd like to have "cray1.domain.com#" or "cray1" as the name of my active secureCRT tab or my active secureCRT windows

**I log on an a server 2, so my prompt is like cray2.domain.com#(shell = tcsh) =>I'd like to have "cray2.domain.com#" or "cray2" as the name of my active secureCRT tab or my active secureCRT windows

** I log to a router, so my prompt is like rt01-emea-cust1# (shell = Cisco IOS) =>I'd like to have "rt01-emea-cust1" as the name of my active secureCRT tab or my active secureCRT windows

** I log to a router, so my prompt is like rt02-emea-cust1# (shell = Cisco IOS) =>I'd like to have "rt02-emea-cust1" as the name of my active secureCRT tab or my active secureCRT windows

** I log to a swtich, so my prompt is like sw01-emea-cust1# (shell = Cisco IOS) =>I'd like to have "sw01-emea-cust1" as the name of my active secureCRT tab or my active secureCRT windows

.......

And so, I'm searching a way to know immediatly (and before switching between the different sessions) "who" are the sessions (Hope I'm understandable ).

Thanks in advance for your help.

PS : I'm using SecureCRT Version 6.6.2 (build 350)
Marc
Reply With Quote
  #6  
Old 04-19-2011, 05:16 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Marc,

Thanks for the additional information. This is definitely something that would be handled by the remote shell. Here is an example of what to set PS1 to on BASH to accomplish your goal:
Code:
[\u@\h]#
This will set the username and the hostname.

I am not familiar enough with tcsh to help you with that shell's prompt command. Additionally, on Cisco devices, we are not aware of a way to configure a prompt that will tell the terminal emulator to change the tab/window title. I would recommend contacting Cisco or a Cisco forum to see if this is possible.

Is this information helpful where BASH is concerned?

If this doesn't help, how are you connecting from the jump host/front door to the other devices?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #7  
Old 04-19-2011, 11:49 PM
mdelor mdelor is offline
Registered User
 
Join Date: Apr 2011
Posts: 5
Hi,
Thanks Todd but, in fact, I was thinking that it is possible, using some secureCRT scripting, to take the prompt (or a part of it) of the active session and to write it on the title bar/tab....
Reply With Quote
  #8  
Old 04-20-2011, 10:20 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Marc,

Thanks for the clarification of your goal. It may be possible to accomplish your goal using a script, but it may not be ideal due to the code that is required to attempt to obtain the prompt. Here is an example:
Code:
' Heuristically determine the shell's prompt.  Crt.Screen.Synchronous must
' already have been set to True.  In general, Crt.Screen.Synchronous should
' be set to True immediately after a successful crt.Session.Connect().  In
' This script, SecureCRT should already be connected -- otherwise, a script
' error will occur.
Do
    ' Simulate pressing "Enter" so the prompt appears again...
    crt.Screen.Send vbcr
    ' Attempt to detect the command prompt heuristically by waiting for the
    ' cursor to stop moving... (the timeout for WaitForCursor above might
    ' not be enough for slower- responding hosts, so you will need to adjust
    ' the timeout value above to meet your system's specific timing
    ' requirements).
    Do
        bCursorMoved = crt.Screen.WaitForCursor(1)
    Loop Until bCursorMoved = False
    ' Once the cursor has stopped moving for about a second, it's assumed
    ' it's safe to start interacting with the remote system. Get the shell
    ' prompt so that it's known what to look for when determining if the
    ' command is completed. Won't work if the prompt is dynamic (e.g.,
    ' changes according to current working folder, etc.)
    nRow = crt.Screen.CurrentRow
    strPrompt = crt.screen.Get(nRow, _
                               0, _
                               nRow, _
                               crt.Screen.CurrentColumn - 1)
    ' Loop until a line of non-whitespace text actually appears:
    strPrompt = Trim(strPrompt)
    If strPrompt <> "" Then Exit Do
Loop
crt.Tab.Caption = strPrompt
You could define this as a logon script. Does this help you accomplish your goal?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #9  
Old 04-20-2011, 11:46 PM
mdelor mdelor is offline
Registered User
 
Join Date: Apr 2011
Posts: 5
Hi Todd,
Thanks for your solution, it's sound good but I have an error when running script : "Object doesn't support this property or method : 'crt.Tab' " .
Do you have an idea?

Regards.

Marc
Reply With Quote
  #10  
Old 04-21-2011, 02:20 AM
mdelor mdelor is offline
Registered User
 
Join Date: Apr 2011
Posts: 5
In fact, it works fine now.
I used crt.Window.Caption = strPrompt.
It's perfect !!!

Many thanks for your help.

Marc
Reply With Quote
  #11  
Old 04-21-2011, 07:28 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi Marc,

Thanks for reporting the problem and letting me know that you found a solution. It is important to note that I only tested the example in SecureCRT 6.6.2, and it does work in this version and should work in newer versions.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 07:16 AM.