So today i created a new VBscript that I figured some of you guys might be able to use. And some of you guys might be able to help add too. Below is a description of the script. Before you ask i used SecureCRT because I couldn't get Telnet.exe to scrap/parse more then the current line with out having it output to a file. (didn't want to go through the trouble.. I do have that script if you want it) And I am learning .Net... meaning I don't know it but i didn't want to mess with the whole .connect thing. Any ways ... Read on
YOU HAVE TO RUN THIS INSIDE SECURE-CRT This script use's Un-Documented commands - I am not responsible for anything
Description: This script opens a predefined list of location/Ip's and logs into them. Then issues a test call ( now this doesn't test individual Dial-peers unless your design is setup with a single dial-peer that meets the criteria of the dialed phone number). It then parses the output to determine if the call was able to be placed and if so was there a setup failure ( line connection problem... so on ) or tone failure ( call was placed and dial-peers and line work correctly)... it then writes that output to a file for further interpretation.
I have an add-on's that I am working on but I am not done... ( e-mailing Output...etc...)
Once agein !!!! This script use's Un-Documented commands - I am not responsible for anything
- Input file structure -
/---------------------------------------
/ Created by: Lucky
/
/ This file contains all the SRST Devices
/ that need to be tested. Add to this list
/ if additional SRST PSTN connections need
/ to be tested. ( * do not add any more txt here)
/----------------------------------------
Location Name ,IPADDRESSS
TESTSITE ,127.0.0.1
- VBscript -
' Status = Working ON
' |==================================================================================
' | %%%% Created by : Lucky
' | %%%% Version : 0.0(1) SecureCRT-version
' | Description: This script opens pre-defined files and attaches to devices found in these files. It then sends
' | a test call to a predefined location. The output is analyzed and if call fail's then location is written
' | to a Failure.txt
' | This script is open to any one that wants to use it, under the condition that I am not held responsible for any thing, EVER!!!
' | Notes * "C:\switch\SRST Check\Program\SRSTLocation.txt" is the folder where active clients are held.
' | Notes* "C:\switch\SRST Check\SRST Check.txt" is the file where Output is written.
' |===================================================================================
Dim objFSO, objTextFile, arrTextFile, DeviceIP, Location, Time
Dim SRSToutputfile, row, screenrow, readline, index, arrFileLines
Dim QualifierCheck0, QualifierCheck1, QualifierCheck2, Qualifier
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Const username = "******" ' Username to use for login
Const password = "******" ' Password for corresponding user
Const Phonenumber = "*******" ' Dialed Test Phone number
Const WorkingDirectory = "C:\switch\SRST Check\" ' Working Directory
Const Outputfilename = "SRST RESULTS.txt" ' name of SRST Check file
Const InputFile = "SRSTLocation.txt" ' The Input File for SRST Locations
Sub Main
Set objFSO = CreateObject("Scripting.FileSystemObject")
Call ClearOldSRSTFile
Call OpenSRSTFile
End Sub
'| --------------------------------------------------------------------------------------------------------------------------------
'| This clears the old SRST log file so that a new one can be create and no old data is proccessed.
'|
Function ClearOldSRSTFile
If objFSO.FileExists(WorkingDirectory & Outputfilename) then
objFSO.DeleteFile(WorkingDirectory & Outputfilename)
End if
End Function
'|_____________________________________________________________________________
'| --------------------------------------------------------------------------------------------------------------------------------
'| This opens the CSV and parse's the file for Ip address, after which it kicks off Login/call Function
'|
Function OpenSRSTFile
Set objTextFile = objFSO.OpenTextFile(WorkingDirectory & InputFile, 1)
' This is used to not read all the header information on the SRST txt file.
objTextFile.Skipline
objTextFile.Skipline
objTextFile.Skipline
objTextFile.Skipline
objTextFile.Skipline
objTextFile.Skipline
objTextFile.Skipline
objTextFile.Skipline
objTextFile.Skipline
Do Until objTextFile.AtEndofStream
arrTextFile = split(objTextFile.Readline, ",") ' splits all data into array for parsing needs
Location = arrTextFile(0) ' Location Name
DeviceIP = arrTextFile(1) ' Device IP with no spaces in name
Call Switchcommands(DeviceIP,Location) ' Call's Switch Function and give variables
loop
End Function
'|_____________________________________________________________________________
'|---------------------------------------------------------------------------------------------------------------------------------------
'| Login/Call function
'|
Function Switchcommands(DeviceIP,Location)
Crt.screen.synchronous = True
' This file is used for output of Location Pots checks.
Set SRSToutputfile = objFSO.OpenTextFile(WorkingDirectory & Outputfilename, ForAppending, True)
' Location Header Information - ( just to make the file look cleaner)
SRSToutputfile.WriteLine(" ///-------------------------------------------\\\ ")
SRSToutputfile.WriteLine(" ----@ " & Location & " ---- ")
SRSToutputfile.WriteLine(" ///---------------------------------------------\\\ ")
crt.Session.Connect "/Telnet " & DeviceIP & " 23" ' Telnets to device that was input into the Swtichcommand
index = crt.Screen.WaitForStrings("Username:", "Password:") ' Used the Predefined Username and Password listed in Const.
If index = 1 Then
crt.Screen.Send username & vbCr
crt.Screen.WaitForString "Password:"
crt.Screen.Send password & vbCr
End If
' These are line commands sent to device.
crt.Screen.WaitForString "#" ' All cisco switch/routers have enable mode that send # as a string
crt.Screen.Send vbCr ' this is just used to clean everything up (cosmetics)
crt.Screen.WaitForString "#"
crt.Screen.Send "! Start Test !" & vbCr ' Starts phone call script (cosmetics)
crt.Screen.WaitForString "#"
crt.Screen.Send "csim start " & Phonenumber & vbCr ' sends Test Call command ( Phonenumber is a Const stated above)
crt.Screen.WaitForString "#"
crt.Screen.Send "! Finished Test !" & vbCr
' Screen scrap - CRT
screenrow = crt.screen.CurrentRow - 2
readline = crt.screen.Get(screenrow, 1, screenrow, 80)
msgbox "this is the readline output = " & readline ' Used for testing
Qualifier = split(readline, ",")
' Qualifier(0) = csime: call attempted = X
' Qualifier(1) = setup failed = x
' Qualifier(2) = tone failed = x
msgbox " This is Qualifier(0) " & Qualifier(0) ' Used for testing
msgbox " This is Qualifier(1) " & Qualifier(1) ' Used for testing
msgbox " This is Qualifier(2) " & Qualifier(2) ' Used for testing
QualifierCheck0 = InStr(Qualifier(0), "csim: call attempted = 1")
On Error Resume Next
QualifierCheck1 = InStr(Qualifier(1), " setup failed = 1")
On Error Resume Next
QualifierCheck2 = InStr(Qualifier(2), " tone failed = 1")
On Error Resume Next
msgbox " This is QualifierCheck0 = " & QualifierCheck0 ' Used for testing
msgbox " This is QualifierCheck1 = " & QualifierCheck1 ' Used for testing
msgbox " This is QualifierCheck2 = " & QualifierCheck2 ' Used for testing
' If the Test is matched with the InStr then a number greate then 0 is given and you are able to match based on that.
if QualifierCheck0 => 1 then
' Used for writing if the Location was checked or not
SRSToutputfile.Write Location & " Test was Performed Correctly" & vbCrLf
If QualifierCheck1 => 1 then
' Setup Failure is due usally to misconfiguration or PhoneLine unplugged.
SRSToutputfile.Write "SETUP FAILED --> CHECK POTS LINES" & vbCrLf
ElseIf QualifierCheck2 => 1 then
' Tone Failure represents that the call was able to be completed and Pots lines work correctly
SRSToutputfile.Write "LOCATION IS WORKING CORRECTLY" & vbCrLf
End if
ElseIf QualifierCheck =0 then
SRSToutputfile.Write Location & " Test was NOT Performed " & vbCrLf
End if
'|----------------------------------------------------------------------------------------------------------------------------------
crt.Screen.Send "Exit" & vbCr
crt.Session.disconnect
SRSToutputfile.close
End function
'|________________________________________________________________________________
[/b]