Can someone help me with Secure CRT VBscript

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
mybox65
Posts: 1
Joined: Thu Feb 02, 2012 1:58 am

Can someone help me with Secure CRT VBscript

Post by mybox65 » Thu Feb 02, 2012 2:10 am

I just created a script for automatically connect to hosts, However I do not know how to create a TXT file to store the failure connection, Please see below , I do appreciate your help !!

# $language = "VBScript"
# $interface = "1.0"
Sub Main
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso,file1,line,str1,params
Set fso = CreateObject("Scripting.FileSystemObject")
Set file1 = fso.OpenTextFile("e:SWbackuplist.txt",Forreading, False) ---------->list.txt is my IP address list
crt.Screen.Synchronous = True
DO While file1.AtEndOfStream <> True
line = file1.ReadLine
params = Split (line)
crt.session.Log(true)
crt.Session.Connect "/TELNET " & params(0)

<<<<Here, I just want to creat a txt file to store unreachable connection and if the connection doesn't work , it can jump to connect another IP>>>>


crt.Screen.WaitForString "Username:"
crt.Screen.Send params(1) & vbcr
crt.Screen.WaitForString "Password:"
crt.Screen.Send params(2) & vbcr
crt.Screen.waitForString "#"
str1 = "show run"
crt.Screen.Send str1 & vbcr
crt.Screen.WaitForString " --More-- "
crt.Screen.Send " " & vbcr
crt.Screen.waitForString "!" & vbcrlf & "end",1
crt.Session.Disconnect
loop
crt.Screen.Synchronous = False
End Sub

User avatar
jvierra
Posts: 13507
Joined: Tue May 22, 2007 9:57 am
Contact:

Can someone help me with Secure CRT VBscript

Post by jvierra » Thu Feb 02, 2012 6:20 am

That is not VBScript.

Where did you get that code. There is not way it will execute in a file with a VBS extension.

Locked