Solved

VBS Carriage Return Convert

Posted on 2012-03-11
6
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 96

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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

752 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