Expect

From MattWiki
Jump to: navigation, search

Expect is a linux command that allows you to run programs like telnet to read the output and act accordingly.

Mythtv Expect Script

#!/usr/bin/expect
spawn telnet 127.0.0.1 6546
expect -exact "# "
send -- "query location\r"
expect {
      "MainMenu" {
        exp_continue
       }
       "Playback Recorded" {
        send "jump mainmenu\r"
        sleep 5
        send "query location\r"
        expect "MainMenu"
        send_user "Well"
        exp_continue
       }
}
send -- "exit\r"
expect eof