
我正在編寫一個腳本來自動執行每天執行數百次的填充任務,例如建立 iOS/Android 項目,但我對 shell 腳本編寫經驗不是很豐富。
在其中一個專案中,我們使用 Titanium,它為我提供了一個圍繞本機構建命令的 CLI 包裝器,所以我這樣做:
titanium build -p ios -T device
將其部署到我的設備上,但在部署之前,我需要選擇一些內容,所以我得到:
Which developer certificate would you like to use?
/Users/bernardo/Library/Keychains/login.keychain
1) CERTIFICATE 1 (xxx) (expires Oct 16, 2015 4:27:51 pm)
2) CERTIFICATE 2 (xxx) (expires Oct 1, 2015 12:06:30 pm)
Select a certificate by number or name:
我總是選擇相同的選項,所以問題是:如何建立一個1
每次都會自動選擇選項的腳本?
謝謝!
編輯:
所以我嘗試使用expect
來選擇該選項。谷歌搜尋後,我這樣做:
expect <<EOD heredoc> spawn titanium build -p ios -T device heredoc> expect "Select a certificate by number or name" heredoc> send "1\r" heredoc> EOD
但是,它不是發送“1”作為輸入,而是顯示“%”。有人知道為什麼嗎?