scp linux 自动化,expect(spawn) 自动化git提交和scp拷贝---centos(linux)
在進(jìn)行SCP文件拷貝中,往往需要進(jìn)行用戶密碼的輸入,即用戶交互。若采用自動(dòng)化腳本的方式進(jìn)行,則可用以下方式
#!/usr/bin/expect
# 設(shè)置參數(shù)
set src [lindex $argv 0]
set dest [lindex $argv 1]
set password [lindex $argv 2]
set appId [lindex $argv 3]
# 進(jìn)行拷貝,采用秘鑰驗(yàn)證(需要輸入秘鑰的密碼 scp的i參數(shù)可指定)方式進(jìn)行
set timeout 2000
spawn scp -i /home/hadoop/.ssh/id_rsa_soa -r $src $dest
expect {
"(yes/no)" {send "yes\r\n";exp_continue} "*passphrase*:" {send "秘鑰的密碼\r\n";exp_continue}
"app*:" {send "$password\r\n"}
}
expect eof
在進(jìn)行g(shù)it的自動(dòng)化提交代碼可用:
#!/usr/bin/expect
cd dir
exec git add .
exec git commit -m "update by yourName"
spawn git push
expect {
"Password*" {send "password\r\n"}
}
expect eof
總結(jié)
以上是生活随笔為你收集整理的scp linux 自动化,expect(spawn) 自动化git提交和scp拷贝---centos(linux)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: android设备报警推送,Fireba
- 下一篇: linux 修改网卡报错xe,cento