Link to home
Start Free TrialLog in
Avatar of cpatte7372
cpatte7372Flag for United Kingdom of Great Britain and Northern Ireland

asked on

VBS Carriage Return Convert

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
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cpatte7372

ASKER

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
Update,

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

Maybe I need to have that somehow represented in the script???
leew,

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

 "|" with vbCr?

Cheers
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....
Cheers