我正在嘗試編寫一個腳本,該腳本從git倉庫中提取最新版本的軟件並更新配置文件。雖然從回購拉,但我必須輸入密碼。我希望腳本自動化所有內容,所以我需要它自動爲我填充。我發現這個網站解釋瞭如何使用「expect」來查找密碼提示併發送密碼。儘管如此,我還是無法使用它。這是我的腳本:在bash腳本中使用expect期望
#!/usr/bin/expect -f
set password [lrange $argv 0 0]
set timeout -1
clear
echo "Updating Source..."
cd sourcedest
git pull -f origin master
match_max 100000
# Look for passwod prompt
expect "*?assword:*"
# Send password aka $password
send -- "$password\r"
# send blank line (\r) to make sure we get back to gui
send -- "\r"
expect eof
git checkout -f master
cp Config/database.php.bak Config/database.php
cp webroot/index.php.bak webroot/index.php
cp webroot/js/config.js.bak webroot/js/config.js
我在做什麼錯?這裏的網站我從它得到:http://bash.cyberciti.biz/security/expect-ssh-login-script/
假設你忘記了菌種。 – bdecaf
我不想那部分。我在我的本地機器中運行這個。 – LordZardeck
沒有git,cd和cp沒有有效的expect命令。你需要爲它產生一個shell。 – bdecaf