expect:Linux Shell 自动化时的交互

安装:

yum install  expect

一个简单的文件同步脚本:

#!/usr/bin/expect
set timeout 1
spawn rsync -avzp  -e ssh  root@服务器ip:/www/wwwroot/website  /www/wwwroot
expect "*password:"
send "服务器密码\r"
interact

注意:

请赋予脚本文件执行权限

运行时直接输入 ./脚本.sh

点赞

发表评论

邮箱地址不会被公开。 必填项已用*标注