#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
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. |
#3
|
|||
|
|||
Quote:
http://forums.vandyke.com/showthread...highlight=bash |
#4
|
|||
|
|||
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. |
#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 |
#6
|
|||
|
|||
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]# 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? |
#7
|
|||
|
|||
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.... |
#8
|
|||
|
|||
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 |
#9
|
|||
|
|||
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 |
#10
|
|||
|
|||
In fact, it works fine now.
![]() I used crt.Window.Caption = strPrompt. It's perfect !!! Many thanks for your help. Marc |
#11
|
|||
|
|||
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. |
![]() |
Thread Tools | |
Display Modes | |
|
|