expect用法举例
1
expect -c '
spawn su - oracle -s check_tablespace.sh
expect "Password:"
send "oracle\n\r"
expect "eof"
exit
'
2 文件形式:
#!/usr/bin/expect -f
spawn su - oracle -s check_tablespace.sh
expect "Password:"
send "oracle\n\r"
expect "eof" #上面的子进程完了会返回eof字符串
exit