View Single Post
  #3  
Old 02-12-2019, 08:51 AM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 41
Quote:
Originally Posted by ekoranyi View Post
Hi BjoernH,

It is unlikely that the WaitForString is simply not waiting, or being skipped, it is likely finding the "$" elsewhere in the output. Is it possible that the output of the preceding command contains a "$" somewhere in the output?
I made some changes but it's still skipping ahead.

Code:
'Declare - nova stop or start
Dim doWhat
doWhat = crt.Dialog.Prompt("Enter 'stop' or 'start' :")
	If doWhat = ""  Then Exit Sub
		MsgBox "Doing " & doWhat & " on " & vNF & " which is a " & vmType & " vm type."
		crt.Screen.Send "echo Start time: `date '+%H:%M:%S'`" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Sleep 50
	
'Start nova commands

If vmType = "cscf" Then
	If doWhat = "start" Then
		crt.Screen.Send"nova list | grep " & vNF & "vm00[1-3] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Sleep"180000"
		crt.Screen.Send"nova list | grep " & vNF & "vm00[6-7] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Sleep"180000"
		crt.Screen.Send"nova list | grep " & vNF & "vm00[4-5] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Screen.Send"nova list | grep " & vNF & "vm10[1-8] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Screen.Send"nova list | grep " & vNF & "vm00[8-9] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Sleep"180000"
		crt.Screen.Send"nova list | grep -E " & vNF & "'vm2[0-4][0-9]|" & vNF & "vm25[0-1]' | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "

		ElseIf doWhat = "stop" Then
		crt.Screen.Send"nova list | grep -E " & vNF & "'vm2[0-4][0-9]|" & vNF & "vm25[0-1]' | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Screen.Send"nova list | grep " & vNF & "vm00[8-9] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Screen.Send"nova list | grep " & vNF & "vm10[1-8] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Screen.Send"nova list | grep " & vNF & "vm00[4-5] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Screen.Send"nova list | grep " & vNF & "vm00[6-7] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Screen.Send"nova list | grep " & vNF & "vm00[1-3] | cut '-d|' -f 3" & vbCr
		crt.Screen.WaitForString "]$ "
	End If

ElseIf vmType = "icsf" Then
	If doWhat = "start" Then
		crt.Screen.Send"nova list | grep " & vNF & "vm10[5-8] | grep -v Running | cut '-d|' -f 3 | xargs nova start" & vbCr
		crt.Screen.WaitForString "]$ "
		MsgBox"Sleeping for 3 minutes."
		crt.Sleep"180000"
		crt.Screen.Send"nova list | grep " & vNF & "vm23[1-4] | grep -v Running | cut '-d|' -f 3 | xargs nova start" & vbCr
		crt.Screen.WaitForString "]$ "

		ElseIf doWhat = "stop" Then
		crt.Screen.Send"nova list | grep " & vNF & "vm23[1-4] | grep -v Shutdown | cut '-d|' -f 3 | xargs nova stop" & vbCr
		crt.Screen.WaitForString "]$ "
		crt.Screen.Send"nova list | grep " & vNF & "vm10[5-8] | grep -v Shutdown | cut '-d|' -f 3 | xargs nova stop" & vbCr
		crt.Screen.WaitForString "]$ "
	End If

End If

	crt.Screen.Send "echo End time: `date '+%H:%M:%S'`" & vbCr
	crt.Screen.WaitForString "]$ "
	MsgBox " *** End nova " & doWhat & " script. *** "

End Sub

So what happens is the following, once it displays the start time, it jumps to the "Sleeping for 3 minutes" MsgBox. It sits there for 3 minutes and then it outputs the first command with the acceptance plus the next 'nova start' command. It's suppose to wait for 3 minutes between the two 'nova start' commands.

I recorded the session, so if you want, I can email you the video and the script.

Regards,
Bjoern
Reply With Quote