使用expect实现shell的交互

1.安装expect

yum install expect

2.编写脚本

demo.exp:

spawn  /var/www/html/imagesDirBackup.sh

expect "password:"

send "ispass\r"

3.这样,当shell脚本中出现了要求输入密码的时候,脚本就自动输入了。

原文地址:https://www.cnblogs.com/chenjianhong/p/4145058.html