Non-Interactive Expect Script - Enjoy!

23 views
Skip to first unread message

Jay Simons

unread,
Dec 29, 2020, 12:08:19 AM12/29/20
to insteon-terminal
Here is an expect script I wrote to automate sending command to the console. It's rough but it works:

<pre><code>
#!/usr/bin/expect -f

set timeout 10

set cmd [lindex $argv 0]

spawn bash

expect "*#"
send "cd /usr/src/insteon-terminal\r"
expect "*#"
send "./insteon-terminal\r"
expect ">>>*"
send "$cmd\r"
expect ">>>*" {
        after 1000
        send "\r"
}
send "\r"
expect ">>>*"
puts "CMD_OK\r"
send "quit()\r"
expect "*#"
send "exit\r"
expect eof
</code></pre>
Reply all
Reply to author
Forward
0 new messages