Skip to content

Instantly share code, notes, and snippets.

@jsimpsoncd
Created April 14, 2018 02:18
Show Gist options
  • Save jsimpsoncd/598ac61e09b462728b4ec7be15d89e5a to your computer and use it in GitHub Desktop.
Save jsimpsoncd/598ac61e09b462728b4ec7be15d89e5a to your computer and use it in GitHub Desktop.
Control an RPC-3 Baytech PDU from the command line
#!/usr/bin/expect
# expect power.expect 192.168.5.3 username password 4 on
# expect power.expect 192.168.5.3 username password 4 off
set timeout 20
set name [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
set outlet [lindex $argv 3]
set state [lindex $argv 4]
spawn telnet $name
# login
expect "Enter username>"
send "$user\r"
expect "Enter password>"
send "$password\r"
# Wait for menu
expect "Outlet Control"
# choose outlet control
send "1\r"
expect "Circuit Breaker"
# set the state of the outlet
send "$state $outlet\r"
expect "Outlet"
send "y\r"
expect "Circuit Breaker"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment