View Single Post
  #3  
Old 12-02-2015, 02:50 PM
WilsonGallardo WilsonGallardo is offline
Registered User
 
Join Date: Nov 2015
Posts: 4
hi, thanks for you answer

* I have a SecureCRT version 7.3.5 (x64 build 903)
* I need create an script to do a ping to many servers, the list ips are in a Mysql database, i need connect SecureCRT to Mysql for run the script
* Database and Segure CRT are in the same pc
* I work in windows 8 and Windows 10
* the complet scrips is the follow. (That script a copy in internet but to Access Database and modify it)

thanks for your help.


#$language = "VBScript"
#$interface = "1.0"


Const ForReading = 1
Const ForWriting = 2
Dim Rst, Cnn, sConn, sTip

Sub Main

crt.Session.Connect "/S PSM_RUN"
Set Cnn = CreateObjet("ADODB.connection")
sConn="Provider=MySQL OBDC 5.3;Data"
Source=MySQL
Cnn.Open(sConn)
sel ="SELECT Cliente,ip,Sede, Tipo FROM direcciones WHERE ip<>''"
Set Rst = Cnn.Execute(sel)
Set fsoerror = CreateObject("Scripting.FileSystemObject")
set fileerror = fsoerror.CreateTextFile("E:\PLANTILLAS DB\errorlogping.txt", True)
Rst.MoveFirst
conterror = 0

Do While Not (Rst.BOF Or Rst.EOF)
str=trim(Rst.Fields("ip").Value)
crt.Screen.Synchronous = True
crt.Screen.Send " ping -c 1 -w 1 -s 8 " & ip & chr(13)
if (crt.Screen.WaitForString(str & " is alive",3)=False) then
crt.Screen.Send Chr(3) & VbCr
fileerror.Write trim(Rst.Fields("ip").Value) & VbCrLf
conterror = conterror + 1
end if

crt.Screen.WaitForString "$",2
crt.Screen.Synchronous = False
Rst.MoveNext
Loop

Rst.Close
Cnn.Close
End Sub
Reply With Quote