#!/usr/bin/expect -- proc login {} { global timeout expect -re "ECHO.*was.*\r\ncmd:" send "c sk5bn\r" set timeout 30 set connected 0 expect { timeout { if { $connected == 0 } { send "d\r" expect -re "\\\*\\\*\\\* DISCONNECTED.*\r\n" send_user "Couldn't connect to BBS, exiting...\n" } else { send_user "No response from BBS, exiting...\n" } exit } -re "\\\*\\\*\\\* CONNECTED.*\r\n" { set connected 1; exp_continue } -re "\\\[FBB-.*]\r\n" { set timeout -1 } } } spawn -nottyinit eterm login interact .