Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-28-2020, 02:28 PM
lordelderwand lordelderwand is offline
Registered User
 
Join Date: May 2020
Posts: 2
Question Script failing to run on multiple systems

I have a customer's environment wherein I need to run a script to fetch output of 6 commands from 120 devices.
I built the following script in my lab to test 2 devices I built up. It shows the output for first file, however does not log and fails for second device throwing error at line 20. Can you please help with what have I done wrong. Secure CRT version is 6.

Code:
#$Language="VBScript"
#$Interface="1.0"

Dim vhosts (2)

vhosts(0) = "1.1.1.1"
vhosts(1) = "2.2.2.1"

Sub Main()
crt.Screen.Synchronous = True
For Each strHost In vHosts
 If strHost = "" Then Exit For

 ' Disconnecting before attempting a new connection
 If crt.Session.Connected Then crt.Session.Disconnect
 ' Connect to the next host
 crt.Session.Connect "/SSH2 /L admin /PASSWORD admin " & strHost
 crt.Session.LogFileName = "W:\lab\%S--%H.log"
	crt.Screen.WaitForString chr(13)
	crt.Screen.Send "show version" & chr(13)
	crt.Screen.WaitForString "<--- More --->"
	crt.Screen.Send "q"
	crt.Screen.WaitForString chr(13)
	Next
 ' Work's done, logout from the system...
 crt.Session.Disconnect
End Sub

Last edited by jdev; 05-29-2020 at 03:44 PM. Reason: Always use [code][/code] tags around your code for preserving indentation/spacing
Reply With Quote
  #2  
Old 05-28-2020, 04:33 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 352
Hi lordelderwand,

Is there a particular reason why you are waiting for a carriage return after connecting to the remote host?

When you manually connect and authenticate are you placed at your prompt?
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 05-29-2020, 02:35 AM
lordelderwand lordelderwand is offline
Registered User
 
Join Date: May 2020
Posts: 2
Thank you for responding. I just put that to ensure logging can be done properly however logging is not working which is a concern.
All help is appreciated.

Since morning, U have been able to resolve logging issues but not the loop piece as script fails at the second device. All help will be appreciated.

Last edited by lordelderwand; 05-29-2020 at 12:19 PM. Reason: Able to close one of two queries.
Reply With Quote
  #4  
Old 05-29-2020, 04:15 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 352
Hi lordelderwand,

Your scripting starter looks like the beginnings of example script that we have made available which runs commands on multiple hosts and logs results to a file. I'm happy to continue helping you troubleshoot your own script, but if there's already something that will work for you, we might as well start with that.

Please refer to the following link:
https://forums.vandyke.com/showpost....94&postcount=1
How well does that script seem like it might work for your needs?
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


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 05:12 PM.