expect用法举例

1     

expect -c '
spawn su - oracle -s check_tablespace.sh
expect "Password:"
send "oracle "
expect "eof"
exit
'

2 文件形式:

#!/usr/bin/expect -f
spawn su - oracle -s check_tablespace.sh
expect "Password:"
send "oracle "
expect "eof"  #上面的子进程完了会返回eof字符串
exit

原文地址:https://www.cnblogs.com/as007012/p/10495918.html