#!/usr/bin/expect -f

# Interactive Brokers TWS Expect module for sawdog

set env(TERM) vt100

set timeout 8
match_max 100000

for {set x 0} {$x<3} {incr x} {
   spawn telnet $argv 3306
   expect "Connection refused" {
      exit 2
   } "Escape character is '^\]'." {
#      expect "220" { 
#         send -- "quit\r"
      exit 0
#      }
   }    
   sleep 5
}
exit 1
