expectでログ出力の制御

expectで実行する際に必要な部分だけをログに出力する方法

test.sh
#!/usr/bin/expect --

send_log "--start--\r"
spawn bash --norc
expect "\$"
send "echo test\r"
expect -re ".*\n"
log_file -noappend log
send_log "$expect_out(0,string)"
log_file
send_log "--end--\n"
exit

    • 実行結果--

$ ./test.sh
spawn bash --norc
echo test

$cat log
$echo test