I have a large script, part of which establishes a remote connection to a *nix box, via putty.
My script will check the machine is online first (ping) before attempting to connect.
However with all things being random as they are, sometimes, for whatever reason, be it a machine that has inner troubles or a service that is not started etc, sometime the connection will hang when there is no reply to putty via ssh.
This will cause my entire sub to fail.
My question is therefore, does any one have any sneaky ways to set a time out.
I am running plink via wshshell.exec so i have the terminate option available to me, however as the script run asynchronously with the connect, if plink hangs when establishing a connection, then my script will never proceed to the terminate line.
loops and such all have the same result because of the asynchronous nature of the script/connection.
The only thing i can think of is maybe creating a temp.vbs file with all the whole connection subroutine inside, and then calling that file via exec and passing the connection variables to it, then setting a loop timer and using a status check to determine if to use .terminate. This will be alot of work, and require rewriting large sections, so i am hoping to avoid this + im not even sure it will give the desired results.