Scripting through a SUT Restart

A question that comes up from time-to-time is the need to run a script that restarts the system under test (SUT). The code referenced below demonstrates the method for scripting through the restart of a Windows system. You’d do something similar for other operating systems.

Step by Step: Scripting through a SUT Restart

The process has several steps:

  1. Store the current connection information to use as the argument to the connect command after the restart.
  2. Script the restart.
  3. Wait for the restart to finish.
  4. Reconnect to the system.

Windows presents a complication that requires a couple of workarounds. The VNC server runs as a service and seems to persist into part of the shutdown process. So the connection will drop initially, but a reconnect could be made briefly while the machine was shutting down. So to ensure that a successful connection takes place after the restart, it’s a good idea to add a check for a visual cue to see that the restart is finished. If it is not, assume that you’ve reconnected during the shutdown, force a disconnect, and start the check over again.

Example:

-- store the current connection information to use as the argument to the connect command later

put connectionInfo() into myConnection

-- do restart here

repeat while connectionInfo().connected is "true"

-- make sure the connection has been closed by the remote system

wait 1

end repeat

-- now try to reconnect

repeat while connectionInfo().connected is not "true"

try

connect myConnection

-- make sure the machine has really restarted

-- the vnc server seems to spring back to life momentarily during shutdown

RefreshScreen

if not imageFound("StartMenu")

disconnect

next repeat

end if

catch

wait 5.0

end try

end repeat

 

This topic was last updated on June 21, 2019, at 02:49:49 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2019 Eggplant