kyo*_*kyo 3 linux git bash shell
git pull在dev/staging/production服务器上执行通常的做法.我经常这样做; 我在运行linux的生产服务器上每天执行git pull几乎100次.
我想,是时候制作一个脚本来改进它.
pull.sh将执行这3个命令
我试过在这里创建我的pull.sh
#!/bin/bash
function pull {
git pull
password
service nginx reload
}
pull ;
Run Code Online (Sandbox Code Playgroud)
结果
运行我的脚本后,我仍然提示输入密码.
任何提示/帮助/建议将不胜感激!
您可以使用expect脚本与git身份验证进行交互:
#!/usr/bin/expect -f
spawn git pull
expect "ass"
send "your_password\r"
interact
Run Code Online (Sandbox Code Playgroud)
它等待"屁股"文本(匹配"密码","密码","密码短语"),然后它发送您的密码.
可以从另一个重启服务器的bash脚本调用该脚本:
# Call script directly since the shell knows that it should run it with
# expect tool because of the first script line "#!/usr/bin/expect -f"
./git-pull-helper-script.sh
# Without the first line "#!/usr/bin/expect -f" the file with commands
# may be sent explicitly to 'expect':
expect file-with-commands
# Restart server
service nginx reload
Run Code Online (Sandbox Code Playgroud)