View Single Post
  #1  
Old 07-24-2018, 01:49 PM
Hang Hang is offline
Registered User
 
Join Date: Jul 2016
Posts: 20
Continuing/Reconnect a script after a network interruption

Hi,

Is there a way to reconnect a connection and continue with the script after a network interruption that causes a session to disconnect?

For example:

If I am running a script and I am sending text on the screen every 3 seconds. Say in between the 3 seconds I have a network glitch and I lost connection, when the 3 seconds is up when it try to send the next command, I would get an error message saying, see below, and my script stop.

Code:
Script Error  
Error: Screen.Send: not connected

File: C:\....
Line 231

Screen.Send.(.....)
Is there a way to config SecureCRT to reconnect and continue on with the script, if a connection is lost?

OR is there a way to ignore this "Error: Screen.Send: not connected" and let the script run, not stop the script completely? I ask because I have implemented a check connection routine at the beginning of the loop to reconnect if the connection got disconnected.

Here is my script:

Code:
checkConn = 0
connAlive = 1
while(1):
 checkConn += 1
 if checkConn != connAlive:
  crt.Session.Connect("/telnet xxx.xxx.xxx.xxx", true, true)  
  checkConn = 0
  connAlive = 0
  
 crt.Screen.Send("hello world\r")
 crt.sleep(3)
 crt.Screen.Send("hello world2\r")
 
 crt.Screen.Send("alive\r")
 if waitfor("alive"):
  connAlive += 1
Say if connection is lost between the hello world and hello world2, I want the script to move on, when it repeat at the top it will know a connection has been lost and will reconnect.

Thanks,

Last edited by Hang; 07-24-2018 at 01:57 PM.
Reply With Quote