#
# EPON interface all ONU flush/deregister
#

if {[llength $argv] != 5} {
puts "Usage: ip username password enablepassword interface"
exit 1
}

set timeout 60


set ip [lindex $argv 0]
set login [lindex $argv 1]
set password [lindex $argv 2]
set enable [lindex $argv 3]
set iface [lindex $argv 4]

spawn telnet $ip

expect "Username:*"
send "$login\r"

expect "Password:*"
send "$password\r"

expect "*>"
send "enable\r"

expect "*#"
send "terminal length 0\r"

expect "*#"
send "config\r"

expect "*#"
send "interface $iface\r"

for {set i 1} {$i <= 64} {incr i} {
    expect "*#"
    send "no epon bind-onu sequence $i\r"
}

expect "*#"
send "exit\r"

expect "*#"
send "exit\r"

expect "*#"
send "write all\r"

expect "*#"
send "exit\r"

expect "*>"
send "exit\r"

