#!/usr/bin/expect

set timeout 3

if {[llength $argv] == 0} {
  send_user "Usage: pdu-expect host [on|off] [1-25]\n"
  exit 1
}

set host [lindex $argv 0]
set onoff [lindex $argv 1]
set number [lindex $argv 2]

spawn telnet $host

expect "User Name :" { send "apc\r" }
# Because of the -c we get a command prompt and not a menu system.
expect "Password  :" { send "apc -c\r" }

# device manager
expect "APC> " { send "$onoff $number\r" }
expect "APC> " { send "\r" }

