Error in the script.
> The following output is displayed in overlayed lines. It
> takes about 30 seconds to run. I had expected to see USR's
*shrugs* Here's the script we run. It logs quite a bit of data - beware. :)
It only runs on USR Courier modems, and has certain expectations about the
portmaster. However, it works really well for finding modem problems.
As with all of my code, use at your own risk. it works here, ymmv.
There are two pieces of code here: The modemstatus program, and the
modem-handler library it makes use of. You need both of them, and
the modem-handler library has to be in a file named just that.
Have fun with it. This is the same basic code we use for testing
modems - a script uses modem-handler to grab a modem on the portmaster
and dial our assigned numbers, logging the connect rate.
You have to pur your portmaster password in the 'YOUR-PASSWORD-HERE'
place.
-Dave
#!/usr/local/bin/expect
##
# Configuration Section
##
set init "s11=50e1m0"
source modem-handler
##
# Handle the command line
##
proc usage {} { puts "Syntax:\nmodemstatus <portmaster> <modem>\n" }
if { [llength $argv] != 2} {
usage
exit
}
set pmname [lindex $argv 0]
set passwd YOUR-PASSWORD-HERE
set umodem [lindex $argv 1]
log_user 0
set timeout 50
spawn telnet $pmname
connect_modem $pmname $passwd
grabmodem $umodem $init
sleep 1
expect "*"
log_user 1
send "ati11\r"
expect "OK"
send "ati6\r"
expect "OK"
log_user 0
exit 1
----------------
The modem-handler code; good stuff.
-----------
##
# connect_modem (portmaster, password for portmaster)
# grabmodem (modem number (sXX), init string (s11=50))
##
proc connect_modem {portmaster passwd} {
expect "login:"
send "!root\r"
expect "assword:"
send "$passwd\r"
expect {
">" { }
timeout {
puts "** Could not connect to portmaster **"
exit 1
}
}
}
proc grabmodem {modem init} {
send "\r"
expect ">"
send "attach $modem\r"
expect {
"configure" {
puts "** Could not attach to modem**"
send "exit\r"
expect eof
exit 1
}
"nnected" { }
}
sleep .5
send "at$init\r"
expect {
"OK" { }
timeout {
puts "** Could not configure modem**"
exit 1
}
}
}