您当前的位置: 首页 >  彭世瑜 git

Linux:expect实现自动拉取git代码

彭世瑜 发布时间:2019-01-24 13:47:39 ,浏览量:3

安装
$ yum install expect
$ where expect
使用
$ expect
expect1.3> expect "hi" {send "hello\n"}
hi
hello
自动拉取git代码

主要解决自动输入账号密码的问题,如果是ssh拉取就不需要使用了 gitpull.exp

#!/usr/bin/expect
set user [lindex $argv 0]
set password [lindex $argv 1]
set timeout 10

spawn git pull
expect "Username*"
send "$user\n"
expect "Password*"
send "$password\n"
expect eof

使用方法

expect gitpull.exp  

替换成自己的账号 替换成自己的密码

参考: Linux-expect命令详解 Expect工具的安装及使用方法

关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 3浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0579s