expectで特別な意味を持つキーワードは timeout, eof, default (defaultはtimeoutとeof両方)
while { true } { send_user "START\n" spawn ssh example.com do_command expect { "assword:" { send "$PASSWORD\r"; wait } timeout { close; wait } eof { wait } } send_user "END\n" sleep 5 }
タイムアウトのときは まだプログラムが生きているから、waitするまえにcloseを呼ぶ必要がある
eofのときはすでにクローズされているのでcloseを呼んではいけない
close済みなのにcloseしたり、wait済みなのにcloseやwaitを呼ぶとエラーになってスクリプトの実行が中断されてしまう やりづらい仕様