Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-05-2014, 07:58 AM
Phen Phen is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
Extracting query strings from telnet url

Hi!
First of all, I would like to say thank you for the great product. It is just awesome.
So what I would like to achieve is that if we have such a url:
telnet://192.168.1.1?title=Router
tab title will change to "Router".
I am trying to do this on my own like this:
changing registry setting to include script and args
extract query title from args
change title using crt.window.caption = title
So far I haven't succeeded, maybe there is better way to do this?
Thank you.

SecureCRT 7.3 for Windows
Reply With Quote
  #2  
Old 12-05-2014, 08:19 AM
Phen Phen is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
I finally managed to do that, but I am still looking for cleaner solution that does not involve passing url as argument.
In case someone needs here is value from registry:
Code:
"C:\Program Files\VanDyke Software\Clients\SecureCRT.exe" /SCRIPT "C:\Program Files\VanDyke Software\Clients\Scripts\ChangeTitleToQuery.py" /ARG %1 /T %1
Here is my python script ChangeTitleToQuery.py:
Code:
#$language = "Python"

#$interface = "1.0"

def main():

    if crt.Arguments.Count > 0:
      first_arg = crt.Arguments[0]
      position = first_arg.find("title=")
      if position > 0:
        title = first_arg[position+6:]
        crt.Window.Caption = title

main()
Reply With Quote
  #3  
Old 12-05-2014, 08:21 AM
bgagnon bgagnon is online now
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hello Phen,

I am not really sure what you are trying to accomplish.

Are you extracting the information to connect SecureCRT telnet sessions from within a script?

Or via the command-line?

Or do you just want to be able to use the existing URL to make connections using SecureCRT?

If the latter option, you would need a wrapper script to handle the arguments (in addition to other configuration steps for making SecureCRT the default URL handler).

We do have an example Telnet Handler wrapper script (VB Script) for ad hoc connections. I have attached it to my post.
Attached Files
File Type: txt DefaultTelnetHandlerWrapperScript(ad hoc).vbs.txt (8.9 KB, 554 views)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #4  
Old 12-05-2014, 09:16 AM
Phen Phen is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
Quote:
Originally Posted by bgagnon View Post
Hello Phen,

I am not really sure what you are trying to accomplish.

Are you extracting the information to connect SecureCRT telnet sessions from within a script?

Or via the command-line?

Or do you just want to be able to use the existing URL to make connections using SecureCRT?

If the latter option, you would need a wrapper script to handle the arguments (in addition to other configuration steps for making SecureCRT the default URL handler).

We do have an example Telnet Handler wrapper script (VB Script) for ad hoc connections. I have attached it to my post.
I am using Cisco Learning Labs and they provide remote access to their devices via such links: telnet://ip:port?title=Router
They also provide modified putty and using that the title of putty window is Router.
But you know, how ugly putty is.
So I decided to make SecureCRT work with this. I managed to open links via registry modification, but window title showed only ip address and since ip address is the same for all devices but ports are different, SecureCRT showed tabs like this: Tab1 title: ip, Tab2 title: ip (1), Tab3 title: ip (2)
I finally managed to change this behaviour using this registry change
Code:
"C:\Program Files\VanDyke Software\Clients\SecureCRT.exe" /SCRIPT "C:\Program Files\VanDyke Software\Clients\Scripts\ChangeTitleToQuery.py" /ARG %1 /T %1
and python script provided above
It works just fine but it seems that it is not the cleanest solution (I pass url two times: 1 for secureCRT execution and another one as an argument for script).

Last edited by jdev; 12-05-2014 at 09:48 AM. Reason: Disable smilies
Reply With Quote
  #5  
Old 12-05-2014, 10:46 AM
bgagnon bgagnon is online now
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,636
Hello Phen,

I know of no alternate method available presently.

I have added this thread to a feature request in our product enhancement database for the ability to connect to hosts specified in URLs without using an argument (wrapper script). Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, contact support@vandyke.com and include "Feature Request - Forum Thread #11811" in the subject line.
__________________
Thanks,
--Brenda

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

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 11:33 AM.