使用expect实现shell的交互

1.安装expect

yum install expect

2.编写脚本

demo.exp:

spawn  /var/www/html/imagesDirBackup.sh

expect "password:"

send "ispass\r"

 

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

 

posted @ 2012-06-28 15:15  jianhong  阅读(132)  评论(0编辑  收藏  举报