简单的脚本,参考下
要交互的脚本(talk.sh)如下:
#!/bin/bash
echo "Who are you?"
read who
echo "Hello,$who"
echo "Are you happy?"
read answer
echo "why?"
read answer
自动化脚本:
#!/bin/bash
expect<<- END
spawn ./talk.sh
expect "who"
send "firefly\n"
expect "happy?"
send "Yes,I am happy.\n"
expect "why?"
send "Because it worked!\n"
expect eof
exit
END