先看下我实际用的例子:

#!/usr/bin/expect
spawn rsync -vazu ssh-src/src wayne@192.168.5.2:~/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需要自己另外安装。

相关文章:

  • 2021-08-31
  • 2022-03-01
  • 2021-09-15
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
猜你喜欢
  • 2021-07-02
  • 2021-11-13
  • 2021-07-28
  • 2021-09-24
  • 2021-08-02
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案