Solved

VBS Carriage Return Convert

Posted on 2012-03-11
6
281 Views
Last Modified: 2012-03-12
Hello Experts,

The following is a part of script that performs a carriage when executed on a router:

& chr(13)

Can someone please tell me if its possible to convert that into an equivalent command like

|

Someone came up with the following:

aryCmds = Split(szCommand, "|").

It does work when directly connected to the device but now through a terminal server.

Cheers

Carlton
0
Comment
Question by:cpatte7372
  • 5
6 Comments
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 500 total points
ID: 37708106
Use Replace.

Replace(Variable, "findCharacter(s)", "ReplaceWithCharacter(s)")

When you need to replace special characters, use the VB equivalents -

vbCr
vbLF
VbCrLf
vbTab

(for example)

More information on Replace:
http://www.w3schools.com/vbscript/func_replace.asp
0
 

Author Comment

by:cpatte7372
ID: 37708121
Experts,

I found out that the carriage return script is keymap used in SecureCRT for VBS is "\r". Maybe that needs to be converted instead of "& chr(13)"? I need help with that.

Cheers

Carlton
0
 

Author Comment

by:cpatte7372
ID: 37708146
Update,

The carriage return is either & vbcrlf or just & vbcr.

Maybe I need to have that somehow represented in the script???
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:cpatte7372
ID: 37708161
leew,

Thanks for responding. I've looked at the example, however, how would I replace

 "|" with vbCr?

Cheers
0
 

Author Comment

by:cpatte7372
ID: 37708165
The actual full script is as follows:

# $language = "VBScript"
# $interface = "1.0"
' SendToAll.vbs

Sub Main()
   
    if Not crt.Session.Connected then
        szSession = crt.Dialog.Prompt("Enter session:", "", "", False)
        if szSession = "" then exit sub
   
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
    end if

    ' Find out what should be sent to all tabs
    szCommand = crt.Dialog.Prompt("Enter command to be sent to all tabs:", _
                                  "Send To All Connected Tabs", "ls", False)
    if szCommand = "" then exit sub
   
    If crt.Dialog.MessageBox(_
        "Are you sure you want to send the following command to " & _
        "__ALL__ tabs?" & vbcrlf & vbcrlf & szCommand, _
        "Send Command To All Tabs - Confirm", _
        vbyesno) <> vbyes then exit sub
   
    ' Connect to each tab in order from left to right, issue a command, and
    ' then disconnect...
    aryCmds = Split(szCommand, "|")

   
        For nIndex = 1 to crt.GetTabCount
            Set objCurrentTab = crt.GetTab(nIndex)
            objCurrentTab.Activate

            If objCurrentTab.Session.Connected = True then
                For Each strOneCmd In aryCmds
            crt.Sleep 500
                objCurrentTab.Screen.Send strOneCmd & vbcr
                crt.Sleep 1000
            Next
            End if
        Next
   
    MsgBox "The following command was sent to all connected tabs:" & vbcrlf & _
        vbcrlf & szCommand

End Sub
                                           
And I need  "|" changed to vbCR, I think....
0
 

Author Closing Comment

by:cpatte7372
ID: 37712373
Cheers
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now