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 08-10-2018, 03:25 PM
DrKubo DrKubo is offline
Registered User
 
Join Date: Aug 2018
Posts: 4
Cool Wait for String?

Hi there,
I'm working on scripts for network-attached legacy devices. They're quite sensitive and I want to let my script check to make sure another user is connected. When another user is issuing commands on the same device, a simultaneously connected user will see their commands being typed out in plain-text. I want to let my script to wait a few seconds while checking for any input before proceeding, otherwise someone is connected and the script should back out of this device.

For example I want to do...

Dim oUser
oUser = crt.Screen.WaitForString(any string whatsoever, 3)

if oUser <> 0 then
quit!!!
else
continue with the script


How can I issue the "waitForString" command such that it will wait for any string?
Reply With Quote
  #2  
Old 08-10-2018, 03:56 PM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 559
Hi DrKubo,

One method I've seen employed is to capture the contents of the screen, wait for a specified amount of time, capture the screen a second time, then compare the two. If the two captures were identical it would likely indicate that another user has not sent any commands.

This relies on new data received being different from the data that was already received. It won't work if, as one example, you have a screenful of 'A's and more 'A's arrive (because one screen "capture" will look exactly like the previous screen "capture").

Code:
strFirstScreen = crt.Screen.Get(1,1,crt.Screen.Rows,crt.Screen.Columns)
'Set how long to wait between screen captures
crt.Sleep 3000
strSecondScreen = crt.Screen.Get(1,1,crt.Screen.Rows, crt.Screen.Columns)

If strSecondScreen <> strFirstScreen Then
    crt.Dialog.MessageBox("The screen contents changed, someone else may be logged in.")
Else
    crt.Dialog.MessageBox("No screen movement, it may be safe to continue.")
End If
Does this help get you the functionality you're looking for?
__________________
Thanks,
--Eric

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

Last edited by ekoranyi; 08-13-2018 at 09:12 AM.
Reply With Quote
  #3  
Old 08-13-2018, 07:34 AM
DrKubo DrKubo is offline
Registered User
 
Join Date: Aug 2018
Posts: 4
Hi Eric,
Thanks for the reply. This is something I considered originally, but just wanted to see if there was an easier way to do it (like if 'waitForString' took regex). This will do the trick, Thanks!
Reply With Quote
  #4  
Old 08-13-2018, 09:12 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 559
Hi DrKubo,

SecureCRT does not currently support the use of RegEx with WaitForString/s. I have added you to a feature request for this functionality. Should this become available in a future version of SecureCRT we will be sure to let you know.

If you would like to be contacted directly please send an email to Support@VanDyke.com with "Feature Request Forum Post 13210" in the subject line.
__________________
Thanks,
--Eric

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

Tags
help please , string


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 09:24 AM.