VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Intermittent Problem With Screen.ReadString (https://forums.vandyke.com/showthread.php?t=13558)

pile0g00 05-21-2019 04:38 PM

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?

berdmann 05-21-2019 04:47 PM

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?

pile0g00 05-21-2019 05:00 PM

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


berdmann 05-21-2019 05:08 PM

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.

pile0g00 05-22-2019 09:39 AM

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.

pile0g00 05-22-2019 10:03 AM

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.

berdmann 05-22-2019 11:51 AM

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?

pile0g00 05-22-2019 06:10 PM

Brittney,

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

Thanks again for your help!

pile0g00 05-30-2019 08:37 AM

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


All times are GMT -6. The time now is 09:21 PM.