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 05-21-2019, 04:38 PM
pile0g00 pile0g00 is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
Intermittent Problem With Screen.ReadString

I am experiencing an intermittent problem with Screen.ReadString(string1, timeoutSeconds).

Sometimes this works fine and other times it will sit there until the timeout, even though I can see the string it is waiting for.

Here is the line of code that fails:
str = tab.Screen.ReadString(StopAt, 300)

StopAt, in this case, is set to "sftp> "

When I am watching this run I can see the cursor sitting at the sftp> prompt, yet it is still waiting. If I hit enter, causing it to just go to the sftp> prompt again it will recognize the sftp> and the script will continue on normally. Any ideas why this is happening?
Reply With Quote
  #2  
Old 05-21-2019, 04:47 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 224
Hi pile0g00,

It sounds like you are experiencing a Synchronous issue, in which the prompt is being sent to the screen faster than the script can account for.

Try settings Synchronous to True and then retest:

Code:
crt.screen.Synchronous = True
If you set Synchronous to true before reading the string does your script run properly?
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 05-21-2019, 05:00 PM
pile0g00 pile0g00 is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
I actually put the following at the top of all of my scripts, this one included
Code:
#$Language="VBScript"
#$Interface="1.0" 

'Prevents problems with strings not being captured when using methods like crt.screen.waitForString
crt.screen.Synchronous = True
'Excludes escape characters when set to true
crt.screen.IgnoreEscape = True
Reply With Quote
  #4  
Old 05-21-2019, 05:08 PM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 224
Hi pile0g00,

In order to get a better understanding of what might be occurring, can you send me your complete script as an attachment to an email to support@vandyke.com, with "ATTN: Brittney, Forum Thread #13558" in the subject field.
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 05-22-2019, 09:39 AM
pile0g00 pile0g00 is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
Brittney,

Thanks for your quick responses. I am working on redacting some information. It is a pretty large script file ~1700 lines and I need to make sure I am not leaving sensitive information in it. I will also try to recreate the issue using a simple version of the script.
Reply With Quote
  #6  
Old 05-22-2019, 10:03 AM
pile0g00 pile0g00 is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
I am finding that it is much easier to recreate when running non-interactive as a scheduled background task. The log shows it waiting the timeout period, but when I run it interactive the issue occurs only intermittently. I think I have a simple working example, but my scripts include a bunch of helper functions by default. I am going to see if I can identify and remove the ones that are not in use by the example.
Reply With Quote
  #7  
Old 05-22-2019, 11:51 AM
berdmann berdmann is offline
VanDyke Technical Support
 
Join Date: Aug 2017
Posts: 224
Hi pile0g00,

It is strange that the issue seems to occur more regularly when you are running a scheduled task!

I can imagine that sifting through 1700+ lines would be the equivalent of searching for the needle in the haystack! Have you tried crafting a simple script that runs the desired command and then reads the string?
__________________
Thanks,
--Brittney

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #8  
Old 05-22-2019, 06:10 PM
pile0g00 pile0g00 is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
Brittney,

I have emailed you a couple of files, the example script and a debug output file.

Thanks again for your help!
Reply With Quote
  #9  
Old 05-30-2019, 08:37 AM
pile0g00 pile0g00 is offline
Registered User
 
Join Date: Dec 2014
Posts: 10
Solved

Thanks for all your help. I think I found the problem. I had a custom function I called echoSend. This would send text and wait to see the text on the terminal. This is a function I have had while scripting in other terminal emulators and it is used to make sure commands don't get jumbled. Technically it should have released the hold once the text was seen in the emulator, so it should not have prevented the capture of the resulting output, but it was unneeded here since Screen.ReedString is going to cause a wait condition anyway. I just replace it with a simple Screen.send and it appears that the script is working again. It is interesting that this has worked for years and just recently started causing me problems... We did recently change servers, so maybe our server is just responding faster now?

Thanks again
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 02:02 AM.