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 03-28-2019, 12:47 PM
Reno Reno is offline
Registered User
 
Join Date: Mar 2019
Posts: 27
VBScript how to ignore Case with Screen.WaitForString

I'm working on a script that (in a loop) SSH's into multiple VM's. I've noticed that randomly (or with certain VM's) the prompt indicating the VM name may be upper case or lower case.

Example: With the inserted text from the array, I need to make the inserted array value case insensitive like where you would UCase two strings to compare them in a case insensitive way.

crt.Screen.WaitForString "[root@" & my_array(x,1) & "admin]# "

Thanks!

Last edited by Reno; 03-28-2019 at 12:47 PM. Reason: type-o
Reply With Quote
  #2  
Old 03-28-2019, 02:26 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 256
Hi Reno,

Please refer to the following example:

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

Do
    strHostPrompt = "[root@myhostnameadmin]#"
    ' We're calling a wrapper function we created to make
    ' it easier to do case-insensitive waits
    WaitForStringCI strHostPrompt
    MsgBox "We found it... moving on..."
Loop

Function WaitForStringCI(strData)
    ' This is a wrapper function that makes case-insensitive
    ' calls to WaitForString much easier...
    '
    ' We're calling WaitForString with the bCaseInsensitive
    ' True|False flag which requires a timeout param. Since
    ' we don't really want this to time out, we'll use an
    ' exceptionally large number of seconds (approximately 7.6
    ' days)
    WaitForStringCI = _
        crt.Screen.WaitForString(strData, (65535 * 10), True)
End Function
__________________
Thanks,
--Brittney

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

Last edited by bgagnon; 03-28-2019 at 03:01 PM. Reason: typo in approximately
Reply With Quote
  #3  
Old 03-28-2019, 03:52 PM
Reno Reno is offline
Registered User
 
Join Date: Mar 2019
Posts: 27
Thank you, that worked perfectly.

Now I'm trying to figure out how to have it loop for only (say) 15 seconds before giving up and exiting with an error message.
Reply With Quote
  #4  
Old 03-28-2019, 06:13 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 256
Hi Reno,

Is this what you are trying to do?

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

Do
    strHostPrompt = "[root@myhostnameadmin]#"
    ' We're calling a wrapper function we created to make
    ' it easier to do case-insensitive waits
    nTimeOut = 15
    If Not WaitForStringCI(strHostPrompt, nTimeout) Then
        MsgBox "Failed to find """ & strHostPrompt & """ within " & nTimeOut & " seconds."
        Exit Do
    Else
        MsgBox "We found it... moving on... (looping again for a look-see)"
    End If
Loop

Function WaitForStringCI(strData, nTimeout)
    ' This is a wrapper function that makes case-insensitive
    ' calls to WaitForString much easier...
    '
    ' We're calling WaitForString with the bCaseInsensitive
    ' True|False flag which requires a timeout param. Since
    ' we don't really want this to time out, we'll use an
    ' exceptionally large number of seconds (approximately 7.6
    ' days)
    WaitForStringCI = _
        crt.Screen.WaitForString(strData, nTimeout, True)
End Function
__________________
Thanks,
--Brittney

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

Last edited by bgagnon; 03-29-2019 at 08:01 AM. Reason: typo (approximaly to approximately)
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:08 AM.