Solved

VBS Carriage Return Convert

Posted on 2012-03-11
6
287 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

821 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