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 05-12-2021, 06:22 PM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 55
Need advice with a simple WaitForStrings query

Good day.

This is supposed to be a simple little script but it's giving me a hard time.

Code:
crt.Screen.Synchronous = True

Sub Main
Dim result
	crt.Screen.Send "grep ^Release /tspinst/scripts/aiParameter.sh|awk -F'=' '{print $2}'" & chr(13)
	result = crt.Screen.WaitForStrings("17.5","19.02", 4)
	MsgBox result
	If result = "17.5" Then 
		crt.Dialog.MessageBox "Release 17"
	Else
		crt.Dialog.MessageBox "Release 19"
	End If
End Sub
When I run this script on a R17.5 system, it returns "Release 19" in the messagebox and 'MsgBox result' returns a "1"

On a R19.02 system the result is also "Release 19" and the 'MsgBox result' returns a "2".

Please advise.

Bjoern
Reply With Quote
  #2  
Old 05-13-2021, 10:18 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
Reading SecureCRT's built-in help documentation, one can see that the return value from a call to the WaitForStrings() method is not a string. Instead, the return value is the *index* of the matched string provided as an parameter when you made the function call.
In other words, if your code looks like this...
Code:
result = crt.Screen.WaitForStrings("17.5","19.02", 4)
...and what appears on your screen is a "19.02", the documentation makes clear that the expected return value is exactly what you are seeing: 2

The value 2 reflects the 2nd string argument you provided to the WaitForStrings("17.5", "19.02", etc.) method is the string that was matched/found on the screen (or, if you sent an array of strings, the 2nd element of that array).

--Jake
Attached Images
File Type: gif SCRT_Help_WaitForStrings_ReturnValues.gif (100.9 KB, 572 views)
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #3  
Old 05-13-2021, 01:21 PM
BjoernH BjoernH is offline
Registered User
 
Join Date: Mar 2018
Posts: 55
Thanks for the explanation Jake!

Changed my script to:

Code:
Sub Main
Dim result
	crt.Screen.Send "grep ^Release /tspinst/scripts/aiParameter.sh|awk -F'=' '{print $2}'" & chr(13)
	result = crt.Screen.WaitForStrings("17.5","19.02", 4)
	MsgBox result
	If result = 1 Then 
		crt.Dialog.MessageBox "Release 17"
	Else
		crt.Dialog.MessageBox "Release 19"
	End If
End Sub
Works as expected now.

Regards,
Bjoern
Reply With Quote
  #4  
Old 05-13-2021, 03:43 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
BjoernH,

You're welcome.

If you want an example of how to use a Select..Case statement in VBScript to handle matches and timeout conditions, check out the VBScript code file in the jump host secondary auth example in our script example sticky.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
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 02:07 AM.