#1
|
|||
|
|||
Changing selected text before searching
Hi,
Sorry for the badly worded title. I am running the script described in 4.1 (Performing a Web Search with Selected Text) in this .pdf: https://www.vandyke.com/support/tips...essentials.pdf I have modified the script a little bit and I am using the script to search for the OUI vendor over at aruljohn.com/mac.pl So I have replaced the following: Code:
' Now search on Google for the information. g_strSearchBase = "http://www.google.com/search?hl=en&q=" Code:
' Now search on Aruljohn for the information. g_strSearchBase = "http://aruljohn.com/mac/" Aruljohn will accept the following: AABBCCDDEEFF Aruljohn will not accept the following: AA:BB:CC:DD:EE:FF or AABB.CCDD.EEFF If I copy a MAC-address from an extreme-switch or juniper-router the format will be AA:BB:CC:DD:EE:FF If I copy a MAC-address from a cisco-router/switch the format will be AABB.CCDD.EEFF What I want the script to do, before searching for the MAC-address on the Aruljohn page, is to remove the ":" and "." so that Aruljohn will accept the format. How do I fix this? Best regards, e2script |
#2
|
|||
|
|||
Hi e2script,
You could use the VBScript Replace() function to remove the undesired characters. Below are 2 examples that expect you have already created a variable with just the MAC: strMac = Replace(strMac, ":", "")Does this help? Last edited by rtb; 04-15-2015 at 08:03 AM. |
#3
|
|||
|
|||
I think I get the idea of what you're saying, but I don't know how to do it in the script.
Script looks like this: Code:
# $language = "VBScript" # $interface = "1.0" Sub Main() strSelection = Trim(crt.Screen.Selection) g_strSearchBase = "http://aruljohn.com/mac/" Set g_shell = CreateObject("WScript.Shell") If strSelection = "" Then Exit Sub Else g_shell.Run chr(34) & g_strSearchBase & strSelection & chr(34) End If End Sub Last edited by e2script; 04-14-2015 at 07:10 AM. Reason: Spelling error |
#4
|
|||
|
|||
Hi e2script,
In the example I offered, you would replace strMac with strSelection. For example: strSelection = Trim(crt.Screen.Selection)Does this help you accomplish your goal? Last edited by rtb; 04-15-2015 at 08:03 AM. Reason: Making solution more clear. |
#5
|
|||
|
|||
Hi Todd,
That's funny because that's exactly what I tried after your first post, but I received an error message so I figured that I did something wrong. I tried again now and I'm still receiving the same error message. Error looks like this: Quote:
I copied your exact lines Code:
strSelection = Replace(strSelection, ":") strSelection = Replace(strSelection, ".") Any input on how to fix this? Thanks for your help so far. |
#6
|
|||
|
|||
I Googled and I found the answer.
Here's what I ended up with: Code:
strSelection = Replace(strSelection, ":", "") strSelection = Replace(strSelection, ".", "") I found out that Aruljohn only accepts MAC's written in uppercase so I aslo added the following line at the bottom. Code:
strSelection = UCase(strSelection) ![]() |
#7
|
|||
|
|||
Hi e2script,
You are correct. I made a mistake. I have edited what I first suggested so that it is correct. |
#8
|
|||
|
|||
I have now encountered a new problem similar to the one we have fixed earlier in this thread.
I'm guessing that this new problem also can be solved using the replace method. What I want the new script to perform is the following: When I copy something to the clipboard from an external source (external as in outside of the SecureCRT terminal window) I want the script to modify the clipboard content before pasting it in the SecureCRT terminal window. For you to better understand the problem at hand I'm going to describe what I'm going to use it for: - I use a system that is mirroring router configuration and displaying it in a GUI - In that GUI there is a text field displaying certain values. Let's use the following value as an example: 123.456 - The problem occurs when I want to log on to a router using SecureCRT to change the configuration on the router, the router doesn't understand 123.456, it only understands 123 unit 456 Example of how the script is going to be used: - I copy 123.456 to the clipboard from an external source. - Then I run a script in SecureCRT changing 123.456 to 123 unit 456 before the script pastes the output in the SecureCRT terminal window. What is the best way to accomplish this? |
#9
|
|||
|
|||
Hi e2script,
Assuming you have already copied the 123.456 text into the clipboard, you'd click a button you've mapped into SecureCRT to run a script to do the pasting for you after modification. Since you're new at this (and there may be others out there that are new to these concepts as well), here's a step-by-step explanation of what you'll want to do:
If I understand what you're trying to accomplish, it doesn't have to be any more complicated than that. If you have enough courage, you can even combine those three lines of code into a single line that looks like this: PHP Code:
Last edited by rtb; 04-27-2015 at 03:30 PM. |
#10
|
|||
|
|||
Hi Todd,
I tried your suggestion today and it worked like a charm ![]() I am really happy that you went into such a detailed explanation. That's really helpful since I'm new at working with vbs and scripting in general. I really appreciate the effort you guys are making to help your customers - thanks a lot. |
#11
|
|||
|
|||
You are welcome e2script. I am glad we could help. Thanks for the feedback.
|
![]() |
Tags |
mac , modify , script , search |
Thread Tools | |
Display Modes | Rate This Thread |
|
|