I have a bash script that connects to a range of server IPs. I am only keyed on a number of these servers at any one time and this can change without notice

I need to add line or two to my script that if a password prompt is detected it will move on to the next server and then run the necessary commands.

Is there a return code or anything for this? Does anyone know a way I can add some sort of timeout function that just moves on if it receives no more communication from the server?