     send -s "\r" 
   }
 
-
-
   if { $result != "test" } {
 
     match_max 50000000
 
-    expect timeout {                                                                                                                                                  send_user " connection timeout\n"
-      break
+    expect timeout {
+      send_user "connection timeout\n"
+      close
+      continue
     } eof {
-      send_user " connection interrupted\n"
-      break
+      send_user "connection interrupted\n"
+      continue
     } "*-> " {
       send -s "exec vfs ls /kav_db\n"
     }
 
-    expect timeout {                                                                                                                                                  send_user " connection timeout\n"
-      break
+    expect timeout {
+      send_user "connection timeout\n"
+      close
+      continue
     } eof {
-      send_user " connection interrupted\n"
-      break
+      send_user "connection interrupted\n"
+      continue
     } "*-> " {
       set data [split $expect_out(buffer) "\n"]
       foreach line $data {

          expect "*->"
        }
      }
      sleep 20
      send -s "exec av scan-mgr pattern-update\r"
    }



  set error 0

  send_user "\[+\] $host - "


  spawn ssh -oControlMaster=auto -oLoglevel=ERROR $username@$host
 
  expect timeout {
    send_user "connection timeout\n"
    close
    continue 
  } eof {
    send_user "connection interrupted\n"
    continue
  } "Permission denied, please try again." {
    send_user " wrong credentials\n"
    continue 
  } "assword:" {
    send -s "$password\r"
    exp_continue
