Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-29-2017, 01:51 PM
respite respite is offline
Registered User
 
Join Date: May 2017
Posts: 6
Post Printing only one line from script

Hello All,

Forgive me, I'm a little new to scripting with CRT. I'm trying to connect to a bunch of hosts and return only one line to a log file instead of printing the entire output from my command. I want to be able to return the line that says AP-51xx firmware version : 2.3.2.0-008R
as I'm specifically looking for for the model, in this case "AP-51xx". We have a few more models than that, I'll be scanning a few hundred devices and would like to be able to say "IP 172.xx.yyy.14x has model APxxxx" if that makes sense.

Here is the script..

#$language = "VBScript"
#$interface = "1.0"
crt.Screen.Synchronous = True

on error resume next


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

crt.Session.Connect "/SSH2 /ACCEPTHOSTKEYS /L ****** /PASSWORD ******* 172.26.25.140"
' Do work on the remote machine.

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

' Disconnect before moving on to the next host
crt.Session.Disconnect

crt.Session.Connect "/SSH2 /ACCEPTHOSTKEYS /L ****** /PASSWORD ****** 172.26.57.140"
' Do work on the remote machine.
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



Here is the messy output. Note: Irrelevant/Sensitive data has been scrubbed.

admin>sum
AP-51xx firmware version : 2.3.2.0-008R
country code : ca
ap-mode : independent
serial number : **********

WLAN 1:
WLAN name : ######
ESS ID : ######
Radio : 11b/g
VLAN : ######
Security Policy : ######
QoS Policy : Default

WLAN 2:
WLAN name : ######
ESS ID : ######
Radio : 11b/g
VLAN : ######
Security Policy : ######
QoS Policy : Default

WLAN 3:
WLAN name : #######
ESS ID : #######
Radio : 11b/g
VLAN : ######
Security Policy : #######
QoS Policy : Default

WLAN 4:
WLAN name : ######
ESS ID : ######
Radio : 11b/g
VLAN : ######
Security Policy : ######
QoS Policy : Default

LAN1 Name: LAN1
LAN1 Mode: enable
LAN1 IP: 172.26.25.140
LAN1 Mask: 255.255.255.0
LAN1 DHCP Mode: static

LAN2 Name: LAN2
LAN2 Mode: disable
LAN2 IP: 192.168.1.1
LAN2 Mask: 255.255.255.0
LAN2 DHCP Mode: static

WAN Interface IP Address Network Mask Default Gateway DHCP Client
------------------------------------------------------------------------------
disable 10.1.1.1 255.0.0.0 0.0.0.0 disable



admin>sum
AP-51xx firmware version : 2.3.2.0-008R
country code : ca
ap-mode : independent
serial number : ***************

WLAN 1:
WLAN name : ######
ESS ID : ######
Radio : 11b/g
VLAN : ######
Security Policy : ######
QoS Policy : Default

WLAN 2:
WLAN name : ######
ESS ID : ######
Radio : 11b/g
VLAN : ######
Security Policy : ######
QoS Policy : Default

WLAN 3:
WLAN name : ######
ESS ID : ######
Radio : 11b/g
VLAN : ######
Security Policy : ######
QoS Policy : Default

WLAN 4:
WLAN name : ######
ESS ID : ######
Radio : 11b/g
VLAN : ######
Security Policy : ######
QoS Policy : Default

LAN1 Name: LAN1
LAN1 Mode: enable
LAN1 IP: 172.26.57.140
LAN1 Mask: 255.255.255.0
LAN1 DHCP Mode: static

LAN2 Name: LAN2
LAN2 Mode: disable
LAN2 IP: 192.168.1.1
LAN2 Mask: 255.255.255.0
LAN2 DHCP Mode: static

WAN Interface IP Address Network Mask Default Gateway DHCP Client
------------------------------------------------------------------------------
disable 10.1.1.1 255.0.0.0 0.0.0.0 disable

Help is greatly appreciated
Reply With Quote
 

Tags
log file , output , ssh


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 10:25 PM.