View Single Post
  #3  
Old 05-31-2017, 10:20 AM
respite respite is offline
Registered User
 
Join Date: May 2017
Posts: 6
Hey

Thanks for the quick reply! I see the logic but I seem to be missing something...

The script is connecting and executing commands but doesn't seem to be logging/searching the variables correctly. In my logfile "AP_Scan_Type_Log.txt"
It only shows has model AP- with nothing else in the text file. No IPs or model numbers.

Here is the updated code: (I've cleaned up how it connects to the hosts, as I'm reading your manuals lol)

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

crt.screen.synchronous = true

on error resume next

Set g_fso = CreateObject("Scripting.FileSystemObject")
Set objFile = g_fso.OpenTextFile("C:\Users\nmorra\Documents\Scripts\logs\AP_Scan_Type_Log.txt", 8, True)

crt.screen.WaitForString("AP-")
strText = crt.screen.ReadString(vbcrlf)

crt.screen.WaitForString("LAN1 IP: ")
strIP = crt.screen.ReadString(vbcrlf)

objFile.Write strIP & " has model AP-" & strText & vbcrlf
objFile.Close

Dim vHosts(100)
vHosts(0) = "172.26.25.140"
vHosts(1) = "172.26.37.140"
vHosts(2) = "172.26.24.140"
vHosts(3) = "172.26.94.140"
vHosts(4) = "172.26.203.140"
vHosts(5) = "172.26.100.140"
vHosts(6) = "172.26.103.140"
vHosts(7) = "172.26.56.140"
vHosts(8) = "172.26.132.140"
vHosts(9) = "172.26.60.140"
vHosts(10) = ""

For Each strHost In vHosts
If strHost = "" Then Exit For

' Make sure we are disconnected before attempting a connection
If crt.Session.Connected Then crt.Session.Disconnect

' Connect to the next host
crt.Session.Connect "/SSH2 /ACCEPTHOSTKEYS /L ****** /PASSWORD ****** " & strHost

crt.session.logfilename="APType_Poll_Output.log"
crt.session.log TRUE, TRUE
crt.Screen.WaitForString "admin>"
crt.Screen.Send "sum" & chr(13)
crt.Screen.WaitForString "admin>"
crt.Screen.Send "quit" & chr(13)
crt.Session.Disconnect
crt.session.log False

next
Reply With Quote