Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-23-2019, 02:51 PM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 55
Getting VBScript runtime error: Object not a collection

Good day.

My vbscript is supposed to log into a number of Linux servers based the type of command(3) and type(2) of remote host. The problem comes in when the script has to choose a vHost array from 4 possible arrays that have been declared.

The script fails at line 307, with a runtime error: "Object is not a collection".

Code:
'#$language = "VBScript"
'#$interface = "1.0"

crt.Screen.Synchronous = True


'Create arrays for VMs
Dim arrStopStandalone(49)
	arrStopStandalone(0)= "192.168.210.20"
	arrStopStandalone(1)= "192.168.210.21"
	arrStopStandalone(2)= "192.168.210.22"
	arrStopStandalone(3)= "192.168.210.23"
	arrStopStandalone(4)= "192.168.210.24"
	arrStopStandalone(5)= "192.168.210.25"
	arrStopStandalone(6)= "192.168.210.26"
	arrStopStandalone(7)= "192.168.210.27"
	arrStopStandalone(8)= "192.168.210.28"
	arrStopStandalone(9)= "192.168.210.29"
	arrStopStandalone(10) = "192.168.210.30"
	arrStopStandalone(11) = "192.168.210.31"
	arrStopStandalone(12) = "192.168.210.32"
	arrStopStandalone(13) = "192.168.210.33"
	arrStopStandalone(14) = "192.168.210.34"
	arrStopStandalone(15) = "192.168.210.35"
	arrStopStandalone(16) = "192.168.210.36"
	arrStopStandalone(17) = "192.168.210.37"
	arrStopStandalone(18) = "192.168.210.38"
	arrStopStandalone(19) = "192.168.210.39"
	arrStopStandalone(20) = "192.168.210.40"
	arrStopStandalone(21) = "192.168.210.41"
	arrStopStandalone(22) = "192.168.210.42"
	arrStopStandalone(23) = "192.168.210.43"
	arrStopStandalone(24) = "192.168.210.44"
	arrStopStandalone(25) = "192.168.210.45"
	arrStopStandalone(26) = "192.168.210.46"
	arrStopStandalone(27) = "192.168.210.47"
	arrStopStandalone(28) = "192.168.210.48"
	arrStopStandalone(29) = "192.168.210.49"
	arrStopStandalone(30) = "192.168.210.50"
	arrStopStandalone(31) = "192.168.210.51"
	arrStopStandalone(32) = "192.168.210.52"
	arrStopStandalone(33) = "192.168.210.53"
	arrStopStandalone(34) = "192.168.210.12"
	arrStopStandalone(35) = "192.168.210.13"
	arrStopStandalone(36) = "192.168.210.14"
	arrStopStandalone(37) = "192.168.210.15"
	arrStopStandalone(38) = "192.168.210.16"
	arrStopStandalone(39) = "192.168.210.17"
	arrStopStandalone(40) = "192.168.210.18"
	arrStopStandalone(41) = "192.168.210.19"
	arrStopStandalone(42) = "192.168.210.5"
	arrStopStandalone(43) = "192.168.210.6"
	arrStopStandalone(44) = "192.168.210.8"
	arrStopStandalone(45) = "192.168.210.9"
	arrStopStandalone(46) = "192.168.210.140"
	arrStopStandalone(47) = "192.168.210.141"
	arrStopStandalone(48) = "192.168.210.142"

Dim arrStartStandalone(49)
	arrStartStandalone(0) = "192.168.210.140"
	arrStartStandalone(1) = "192.168.210.141"
	arrStartStandalone(2) = "192.168.210.142"
	arrStartStandalone(3) = "192.168.210.5"
	arrStartStandalone(4) = "192.168.210.6"
	arrStartStandalone(5) = "192.168.210.8"
	arrStartStandalone(6) = "192.168.210.9"
	arrStartStandalone(7) = "192.168.210.12"
	arrStartStandalone(8) = "192.168.210.13"
	arrStartStandalone(9) = "192.168.210.14"
	arrStartStandalone(10) = "192.168.210.15"
	arrStartStandalone(11) = "192.168.210.16"
	arrStartStandalone(12) = "192.168.210.17"
	arrStartStandalone(13) = "192.168.210.18"
	arrStartStandalone(14) = "192.168.210.19"
	arrStartStandalone(15) = "192.168.210.20"
	arrStartStandalone(16) = "192.168.210.21"
	arrStartStandalone(17) = "192.168.210.22"
	arrStartStandalone(18) = "192.168.210.23"
	arrStartStandalone(19) = "192.168.210.24"
	arrStartStandalone(20) = "192.168.210.25"
	arrStartStandalone(21) = "192.168.210.26"
	arrStartStandalone(22) = "192.168.210.27"
	arrStartStandalone(23) = "192.168.210.28"
	arrStartStandalone(24) = "192.168.210.29"
	arrStartStandalone(25) = "192.168.210.30"
	arrStartStandalone(26) = "192.168.210.31"
	arrStartStandalone(27) = "192.168.210.32"
	arrStartStandalone(28) = "192.168.210.33"
	arrStartStandalone(29) = "192.168.210.34"
	arrStartStandalone(30) = "192.168.210.35"
	arrStartStandalone(31) = "192.168.210.36"
	arrStartStandalone(32) = "192.168.210.37"
	arrStartStandalone(33) = "192.168.210.38"
	arrStartStandalone(34) = "192.168.210.39"
	arrStartStandalone(35) = "192.168.210.40"
	arrStartStandalone(36) = "192.168.210.41"
	arrStartStandalone(37) = "192.168.210.42"
	arrStartStandalone(38) = "192.168.210.43"
	arrStartStandalone(39) = "192.168.210.44"
	arrStartStandalone(40) = "192.168.210.45"
	arrStartStandalone(41) = "192.168.210.46"
	arrStartStandalone(42) = "192.168.210.47"
	arrStartStandalone(43) = "192.168.210.48"
	arrStartStandalone(44) = "192.168.210.49"
	arrStartStandalone(45) = "192.168.210.50"
	arrStartStandalone(46) = "192.168.210.51"
	arrStartStandalone(47) = "192.168.210.52"
	arrStartStandalone(48) = "192.168.210.53"

Dim arrStartCore(71)
	arrStartCore(0) = "192.168.210.140"
	arrStartCore(1) = "192.168.210.141"
	arrStartCore(2) = "192.168.210.142"
	arrStartCore(3) = "192.168.210.5"
	arrStartCore(4) = "192.168.210.6"
	arrStartCore(5) = "192.168.210.143"
	arrStartCore(6) = "192.168.210.144"
	arrStartCore(7) = "192.168.210.8"
	arrStartCore(8) = "192.168.210.9"
	arrStartCore(9) = " 192.168.210.12"
	arrStartCore(10) = "192.168.210.13"
	arrStartCore(11) = "192.168.210.14"
	arrStartCore(12) = "192.168.210.15"
	arrStartCore(13) = "192.168.210.16"
	arrStartCore(14) = "192.168.210.17"
	arrStartCore(15) = "192.168.210.18"
	arrStartCore(16) = "192.168.210.19"
	arrStartCore(17) = "192.168.210.20"
	arrStartCore(18) = "192.168.210.21"
	arrStartCore(19) = "192.168.210.22"
	arrStartCore(20) = "192.168.210.23"
	arrStartCore(21) = "192.168.210.24"
	arrStartCore(22) = "192.168.210.25"
	arrStartCore(23) = "192.168.210.26"
	arrStartCore(24) = "192.168.210.27"
	arrStartCore(25) = "192.168.210.28"
	arrStartCore(26) = "192.168.210.29"
	arrStartCore(27) = "192.168.210.30"
	arrStartCore(28) = "192.168.210.31"
	arrStartCore(29) = "192.168.210.32"
	arrStartCore(30) = "192.168.210.33"
	arrStartCore(31) = "192.168.210.34"
	arrStartCore(32) = "192.168.210.35"
	arrStartCore(33) = "192.168.210.36"
	arrStartCore(34) = "192.168.210.37"
	arrStartCore(35) = "192.168.210.38"
	arrStartCore(36) = "192.168.210.39"
	arrStartCore(37) = "192.168.210.40"
	arrStartCore(38) = "192.168.210.41"
	arrStartCore(39) = "192.168.210.42"
	arrStartCore(40) = "192.168.210.43"
	arrStartCore(41) = "192.168.210.44"
	arrStartCore(42) = "192.168.210.45"
	arrStartCore(43) = "192.168.210.46"
	arrStartCore(44) = "192.168.210.47"
	arrStartCore(45) = "192.168.210.48"
	arrStartCore(46) = "192.168.210.49"
	arrStartCore(47) = "192.168.210.50"
	arrStartCore(48) = "192.168.210.51"
	arrStartCore(49) = "192.168.210.52"
	arrStartCore(50) = "192.168.210.53"
	arrStartCore(51) = "192.168.210.54"
	arrStartCore(52) = "192.168.210.55"
	arrStartCore(53) = "192.168.210.56"
	arrStartCore(54) = "192.168.210.57"
	arrStartCore(55) = "192.168.210.58"
	arrStartCore(56) = "192.168.210.59"
	arrStartCore(57) = "192.168.210.60"
	arrStartCore(58) = "192.168.210.61"
	arrStartCore(59) = "192.168.210.62"
	arrStartCore(60) = "192.168.210.63"
	arrStartCore(61) = "192.168.210.64"
	arrStartCore(62) = "192.168.210.65"
	arrStartCore(63) = "192.168.210.66"
	arrStartCore(64) = "192.168.210.67"
	arrStartCore(65) = "192.168.210.68"
	arrStartCore(66) = "192.168.210.69"
	arrStartCore(67) = "192.168.210.70"
	arrStartCore(68) = "192.168.210.71"
	arrStartCore(69) = "192.168.210.72"
	arrStartCore(70) = "192.168.210.73"

Dim arrStopCore(71)
	arrStopCore(0) = "192.168.210.20"
	arrStopCore(1) = "192.168.210.21"
	arrStopCore(2) = "192.168.210.22"
	arrStopCore(3) = "192.168.210.23"
	arrStopCore(4) = "192.168.210.24"
	arrStopCore(5) = "192.168.210.25"
	arrStopCore(6) = "192.168.210.26"
	arrStopCore(7) = "192.168.210.27"
	arrStopCore(8) = "192.168.210.28"
	arrStopCore(9) = "192.168.210.29"
	arrStopCore(10) = "192.168.210.30"
	arrStopCore(11) = "192.168.210.31"
	arrStopCore(12) = "192.168.210.32"
	arrStopCore(13) = "192.168.210.33"
	arrStopCore(14) = "192.168.210.34"
	arrStopCore(15) = "192.168.210.35"
	arrStopCore(16) = "192.168.210.36"
	arrStopCore(17) = "192.168.210.37"
	arrStopCore(18) = "192.168.210.38"
	arrStopCore(19) = "192.168.210.39"
	arrStopCore(20) = "192.168.210.40"
	arrStopCore(21) = "192.168.210.41"
	arrStopCore(22) = "192.168.210.42"
	arrStopCore(23) = "192.168.210.43"
	arrStopCore(24) = "192.168.210.44"
	arrStopCore(25) = "192.168.210.45"
	arrStopCore(26) = "192.168.210.46"
	arrStopCore(27) = "192.168.210.47"
	arrStopCore(28) = "192.168.210.48"
	arrStopCore(29) = "192.168.210.49"
	arrStopCore(30) = "192.168.210.50"
	arrStopCore(31) = "192.168.210.51"
	arrStopCore(32) = "192.168.210.52"
	arrStopCore(33) = "192.168.210.53"
	arrStopCore(34) = "192.168.210.54"
	arrStopCore(35) = "192.168.210.55"
	arrStopCore(36) = "192.168.210.56"
	arrStopCore(37) = "192.168.210.57"
	arrStopCore(38) = "192.168.210.58"
	arrStopCore(39) = "192.168.210.59"
	arrStopCore(40) = "192.168.210.60"
	arrStopCore(41) = "192.168.210.61"
	arrStopCore(42) = "192.168.210.62"
	arrStopCore(43) = "192.168.210.63"
	arrStopCore(44) = "192.168.210.64"
	arrStopCore(45) = "192.168.210.65"
	arrStopCore(46) = "192.168.210.66"
	arrStopCore(47) = "192.168.210.67"
	arrStopCore(48) = "192.168.210.68"
	arrStopCore(49) = "192.168.210.69"
	arrStopCore(50) = "192.168.210.70"
	arrStopCore(51) = "192.168.210.71"
	arrStopCore(52) = "192.168.210.72"
	arrStopCore(53) = "192.168.210.73"
	arrStopCore(54) = "192.168.210.12"
	arrStopCore(55) = "192.168.210.13"
	arrStopCore(56) = "192.168.210.14"
	arrStopCore(57) = "192.168.210.15"
	arrStopCore(58) = "192.168.210.16"
	arrStopCore(59) = "192.168.210.17"
	arrStopCore(60) = "192.168.210.18"
	arrStopCore(61) = "192.168.210.19"
	arrStopCore(62) = "192.168.210.5"
	arrStopCore(63) = "192.168.210.6"
	arrStopCore(64) = "192.168.210.143"
	arrStopCore(65) = "192.168.210.144"
	arrStopCore(66) = "192.168.210.8"
	arrStopCore(67) = "192.168.210.9"
	arrStopCore(68) = "192.168.210.140"
	arrStopCore(69) = "192.168.210.141"
	arrStopCore(70) = "192.168.210.142"


Sub Main()

'Check if user is rtp99
	crt.Screen.Send "whoami" & vbCr
	If Not crt.Screen.WaitForString("rtp99", 2) Then
		MsgBox "You must be rtp99 user to execute this script!"
	Exit Sub
	End If

'Prompt for root password
	Dim passR
		passR = crt.Dialog.Prompt("Enter the ROOT password:", "Logon Script", "", True)
	If passR = ""  Then Exit Sub


'Identify VM type (cscf or icsf)
Dim vmType
	crt.Screen.Send "hostname | cut -c 6-9" & vbCr
		If crt.Screen.WaitForString("cscf", 2) Then
			vmType = "Core"
		Else
			vmType = "Standalone"
		End If

	
'Declare - status, stop or start rtp
	Dim doWhat
doWhat = crt.Dialog.Prompt("Enter 'status', 'stop' or 'start' :")
	If doWhat = ""  Then Exit Sub

Dim strDoCommand
		If doWhat = "start" Then 
			strDoCommand = "start rtp & disown"
		ElseIf doWhat = "stop" Then
			strDoCommand = "stop rtp & disown"
		Else
			strDoCommand = "status rtp | grep 'Active:' | grep -v 'active (exited)'"
		End If

Dim vHost
	If doWhat = "start" Then
		vHost = "arrStart" & vmType
	ElseIf doWhat = "start" Then
		vHost= "arrStop" & vmType
	Else
		vHost = "arrStart" & vmType
	End If
	MsgBox(strDoCommand) 'Correct as expected
	MsgBox(vHost)        'Correct as expected

For Each strHosts In vHost
    If strHosts = "" Then Exit For
	
    crt.Screen.Send"ssh -q " & strHosts & vbCr


Dim vWaitFors
vWaitFors = Array("(yes/no)?", _
					"bash-4", _
					"No route to host")

Do
	Dim nResult
	nResult = crt.Screen.WaitForStrings(vWaitFors, 1)

	Select Case nResult
		Case 0
'			MsgBox "Timed out waiting for strings!"
			crt.Sleep 100
			Exit Do

		Case 1
'		MsgBox "This is Case 1"
			crt.Screen.Send"yes" & vbCr
			crt.Screen.WaitForString"$"
			
		Case 2
'		MsgBox "This is Case 2"
			crt.Screen.WaitForString"$"
 
		Case 3
'		MsgBox "This is Case 2, No route to host."
		crt.Sleep 1000
			Exit Do


	End Select

	crt.Screen.Send"su - root" &vbCr
	crt.Sleep 5
	crt.Screen.WaitForString"assword"
	crt.Sleep 5
	crt.Screen.Send passR & vbCr
	crt.Screen.WaitForString">"
	crt.Screen.Send"echo;hostname;systemctl " & strDoCommand & vbCr
	crt.Screen.WaitForString">"
	crt.Screen.Send"exit" & vbCr
	crt.Screen.WaitForString"-bash-4.2$"
	crt.Screen.Send"exit" & vbCr
	crt.Screen.WaitForString"-bash-4.2$"
Loop
	crt.Sleep 1

Next
	MsgBox " *** End RTP script. *** "
	
End Sub

Any ideas?


Regards,
Bjoern
Reply With Quote
  #2  
Old 01-23-2019, 03:22 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi BjoernH,

Looking at line 307, it appears that vHost is a string, rather than an array.

If you add the below line of code right before line 307, what is the reported type of the vHost variable?
Code:
crt.Dialog.MessageBox(TypeName(vHost))
From what I see earlier in the code vHost is made up of either the string arrStart or arrStop and vmType. vmType itself is a string of either Core or Standalone. It appears that vHost is simply a concatenation of two strings not a reference to the actual array.

You may be able to resolve this issue using the Eval function.
Code:
For Each strHosts In Eval(vHost)
Does making this change give you the behavior you're looking for?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 01-24-2019, 08:58 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 55
Thanks Eric! Working like a charm.

One more question, how would you insert a pause (sleep) between two vHosts in each array, eg:

Code:
Dim arrStartStandalone(49)
	arrStartStandalone(0) = "192.168.210.140"
	arrStartStandalone(1) = "192.168.210.141"
	arrStartStandalone(2) = "192.168.210.142"
Insert sleep here
	arrStartStandalone(3) = "192.168.210.5"
	arrStartStandalone(4) = "192.168.210.6"
Regards,
Bjoern
Reply With Quote
  #4  
Old 01-24-2019, 09:05 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
BjoernH,

You won't be able to insert a sleep or pause in the array directly, this is something that would need to be done inside your For loop. This does limit the flexibility as the sleep would need to happen between every host or not at all.

Perhaps with a better understanding of the problem I can help suggest an alternative approach. What problem are you trying to solve with the sleep?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 01-24-2019, 09:13 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 55
Quote:
Originally Posted by ekoranyi View Post
BjoernH,

You won't be able to insert a sleep or pause in the array directly, this is something that would need to be done inside your For loop. This does limit the flexibility as the sleep would need to happen between every host or not at all.

Perhaps with a better understanding of the problem I can help suggest an alternative approach. What problem are you trying to solve with the sleep?
When starting RTP on the servers, I need a 5 minute pause between certain types of servers. So for instance, after starting RTP on the first three servers .141, .142, 143, I need a pause so that they are fully enabled before starting RTP on the next two.

Bjoern
Reply With Quote
  #6  
Old 01-24-2019, 09:37 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
BjoernH,

How many of the servers will require a sleep? Perhaps adding an If statement inside the For Each strHosts In vHost loop to check for these IP's and add a sleep would work.

The pseudo code below should help demonstrate this idea.

Code:
For Each strHosts In vHost
    If strHosts = "192.168.210.5"
        crt.Sleep <millisec>
    End If
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #7  
Old 01-24-2019, 10:03 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 55
Quote:
Originally Posted by ekoranyi View Post
BjoernH,

How many of the servers will require a sleep? Perhaps adding an If statement inside the For Each strHosts In vHost loop to check for these IP's and add a sleep would work.

The pseudo code below should help demonstrate this idea.

Code:
For Each strHosts In vHost
    If strHosts = "192.168.210.5"
        crt.Sleep <millisec>
    End If
I have rearranged the hosts as they should be. The pauses are required in the start RTP arrays only, not for status or stop:

Code:
Stand-alone:
Dim arrStartStandalone(49)
	arrStartStandalone(0) = "192.168.210.140"
	arrStartStandalone(1) = "192.168.210.141"
	arrStartStandalone(2) = "192.168.210.142"
Sleep here
	arrStartStandalone(3) = "192.168.210.5"
	arrStartStandalone(4) = "192.168.210.6"
	arrStartStandalone(5) = "192.168.210.12"
	arrStartStandalone(6) = "192.168.210.13"
	arrStartStandalone(7) = "192.168.210.14"
	arrStartStandalone(8) = "192.168.210.15"
	arrStartStandalone(9) = "192.168.210.16"
	arrStartStandalone(10) = "192.168.210.17"
	arrStartStandalone(11) = "192.168.210.18"
	arrStartStandalone(12) = "192.168.210.19"
	arrStartStandalone(13) = "192.168.210.8"
	arrStartStandalone(14) = "192.168.210.9"
Sleep here
	arrStartStandalone(15) = "192.168.210.20"
	arrStartStandalone(16) = "192.168.210.21"
	arrStartStandalone(17) = "192.168.210.22"
	
	
Core:
Dim arrStartCore(71)
	arrStartCore(0) = "192.168.210.140"
	arrStartCore(1) = "192.168.210.141"
	arrStartCore(2) = "192.168.210.142"
	arrStartCore(3) = "192.168.210.143"
	arrStartCore(4) = "192.168.210.144"
Sleep here
	arrStartCore(5) = "192.168.210.5"
	arrStartCore(6) = "192.168.210.6"
	arrStartCore(7) = "192.168.210.12"
	arrStartCore(8) = "192.168.210.13"
	arrStartCore(9) = "192.168.210.14"
	arrStartCore(10) = "192.168.210.15"
	arrStartCore(11) = "192.168.210.16"
	arrStartCore(12) = "192.168.210.17"
	arrStartCore(13) = "192.168.210.18"
	arrStartCore(14) = "192.168.210.19"
	arrStartCore(15) = "192.168.210.8"
	arrStartCore(16) = "192.168.210.9"
Sleep here
	arrStartCore(17) = "192.168.210.20"
	arrStartCore(18) = "192.168.210.21"
	arrStartCore(19) = "192.168.210.22"
If you can show me one example on the stand-alone, I'll try it on the core myself.

P.S I need a 5 minute pause, if that's possible.


Bjoern

Last edited by BjoernH; 01-24-2019 at 10:12 AM. Reason: Added PS
Reply With Quote
  #8  
Old 01-24-2019, 10:22 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
BjoernH,

I may have gotten a bit ahead of myself, perhaps there is a way to add the sleeps directly into your array.

This might look something like:
Code:
Dim arrStartStandalone(49)
    arrStartStandalone(0) = "192.168.210.140"
    arrStartStandalone(1) = "192.168.210.141"
    arrStartStandalone(2) = "192.168.210.142"
' Need some time for the priors to start up
' before we move on to the next group.
' 5 minutes should be good enough:
    arrStartStandalone(3) = "crt.Sleep 60 * 5 * 1000"
    arrStartStandalone(4) = "192.168.210.5"
    arrStartStandalone(5) = "192.168.210.6"
' The next set needs 7 minutes instead of 5:
    arrStartStandalone(6) = "crt.Sleep 60 * 7 * 1000"
    arrStartStandalone(7) = "192.168.210.201"
    arrStartStandalone(8) = "192.168.210.202"
' .
' .
' .
You could then use the If statement to check if the array entry contains sleep and take the appropriate action.

Code:
For Each strHost in vHosts
    If Instr(strHost, "crt.Sleep") Then
        ' Execute the sleep statement contained in this array entry
        Eval(strHost)
    Else
        ' Do the work of connecting, etc...
    End If
Next
Does this provide the needed functionality?
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #9  
Old 01-24-2019, 10:48 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 55
Quote:
Originally Posted by ekoranyi View Post
BjoernH,

I may have gotten a bit ahead of myself, perhaps there is a way to add the sleeps directly into your array.

This might look something like:
Code:
Dim arrStartStandalone(49)
    arrStartStandalone(0) = "192.168.210.140"
    arrStartStandalone(1) = "192.168.210.141"
    arrStartStandalone(2) = "192.168.210.142"
' Need some time for the priors to start up
' before we move on to the next group.
' 5 minutes should be good enough:
    arrStartStandalone(3) = "crt.Sleep 60 * 5 * 1000"
    arrStartStandalone(4) = "192.168.210.5"
    arrStartStandalone(5) = "192.168.210.6"
' The next set needs 7 minutes instead of 5:
    arrStartStandalone(6) = "crt.Sleep 60 * 7 * 1000"
    arrStartStandalone(7) = "192.168.210.201"
    arrStartStandalone(8) = "192.168.210.202"
' .
' .
' .
You could then use the If statement to check if the array entry contains sleep and take the appropriate action.

Code:
For Each strHost in vHosts
    If Instr(strHost, "crt.Sleep") Then
        ' Execute the sleep statement contained in this array entry
        Eval(strHost)
    Else
        ' Do the work of connecting, etc...
    End If
Next
Does this provide the needed functionality?
Thanks Eric, I'll try that. In the meantime I was messing with this, but it barfed.

Code:
'ssh to VMs
	For Each strHosts In Eval(vHost)
    If strHosts = "" Then Exit For

	If doWhat = "start" Then
		If strHosts = "192.168.210.[5, 20] Then 
			crt.Sleep 100000
        End If

    crt.Screen.Send"ssh -q " & strHosts & vbCr

Bjoern
Reply With Quote
  #10  
Old 01-24-2019, 12:39 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
BjoernH,

It appears that you're trying to supply a range in your if statement. I haven't seen that syntax used before, can you point me to some documentation on its use?

Generally I see ranges with the syntax:
Code:
If strMyVal >= 5 And strMyVal <= 20 Then
In your case this would be a little more complex, you won't be able to use the full IP address. You may be able to use the Split function to split the IP and capture only the last octet. You could then compare against the value of the last octet.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #11  
Old 01-31-2019, 07:30 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 55
Quote:
Originally Posted by ekoranyi View Post
BjoernH,

It appears that you're trying to supply a range in your if statement. I haven't seen that syntax used before, can you point me to some documentation on its use?

Generally I see ranges with the syntax:
Code:
If strMyVal >= 5 And strMyVal <= 20 Then
In your case this would be a little more complex, you won't be able to use the full IP address. You may be able to use the Split function to split the IP and capture only the last octet. You could then compare against the value of the last octet.
Hi Eric, sorry for the delayed reply, I didn't have access to the lab due to upgrades.

I have been able to make it work using this:

Code:
'ssh to VMs
	For Each strHosts In Eval(vHost)
    If strHosts = "" Then Exit For

	If doWhat = "start" Then
		If (strHosts = "192.168.210.5") OR (strHosts = "192.168.210.20") Then
			crt.Sleep 300000
		End If
	End If
    crt.Screen.Send"ssh -q " & strHosts & vbCr
I'll email the entire script if you wish me to do so.


Rergards,
Bjoern
Reply With Quote
  #12  
Old 01-31-2019, 08:07 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 654
Hi BjoernH,

I'm glad to hear you found a solution that provides the behavior you're looking for. Thanks for the update!
__________________
Thanks,
--Eric

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

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 06:49 PM.