zl程序教程

您现在的位置是:首页 >  其他

当前栏目

与服务器同步工程(expect脚本)详解程序员

同步服务器程序员 详解 脚本 工程 expect
2023-06-13 09:20:04 时间
#!/usr/bin/expect 

spawn rsync -vazu ssh-src/src [email protected]:~/projects/ 

expect "*password:" 

expect "*#" 

send "wayne/n" 

#expect "*#" 

interact

这里面用了rsync与服务器同步,用了expect自动填写服务器密码。

简单解释:

send:用于向进程发送字符串 

expect:从进程接收字符串 

spawn:启动新的进程 

interact:允许用户交互

详细解释参考:https://blog.csdn.net/heqiyu34/article/details/53842126

 

注意这是expect脚本,一般我这么执行:expect *.expect

expect需要自己另外安装。

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/2722.html

服务器部署程序员系统优化网站设置运维