#!/usr/bin/expect -f
# Sample telnet automation
## call with autotel host username password

set host [lindex $argv 0]
# set rcfile [open ~/.autotel/$host  r ]
# gets $rcfile user
# gets $rcfile pass
# spawn telnet  "$host"
# spawn telnet  "192.168.1.132" "9999"
spawn telnet  "$host" "9999"
expect "Press Enter for Setup Mode"
send "\r"
expect "Your choice ?" 
send "7\r"
expect "Your choice ?" 
send "1\r"
# Channel 1:Serial Settings:Baud rate: 115200
# Configurable pins:CP2: HW Flow Control In (CTS from microcontroller)
# Channel 1:Serial Settings:Flow control: CTS/RTS Hardware
expect { 
"Baudrate" {send "115200\r" ; exp_continue}
"I/F Mode" {send "\r" ; exp_continue}
"Flow (" {send "02\r" ; exp_continue}
"Port No (" {send "\r" ; exp_continue}
"ConnectMode " {send "\r" ; exp_continue}
"Send '+++' in Modem Mode  (" {send "\r" ; exp_continue}
"Show IP addr after 'RING'  " {send "\r" ; exp_continue}
"Auto increment source port  " {send "\r" ; exp_continue}
"Remote IP Address :" {send "\r\r\r\r" ; exp_continue}
"Remote Port  (" {send "\r" ; exp_continue}
"DisConnMode (" {send "\r" ; exp_continue}
"FlushMode   (" {send "\r" ; exp_continue}
"DisConnTime (" {send "\r\r" ; exp_continue}
"SendChar 1" {send "\r" ; exp_continue}
"SendChar 2" {send "\r"}
}
expect "Your choice ?" 
send "9\r"

interact
