#!/usr/bin/expect set args [lrange $argv 0 end] set timeout 300 spawn {*}$args expect "root@testvm:~#" set timeout 10 send "echo 6coF0JBW\$((2+3))\r" expect { "6coF0JBW5" { } timeout { exit 1 } } expect "root@testvm:~#" send "poweroff\r" set timeout 120 expect eof