0
這是最終目標:在提示時使用expect腳本執行mysql命令以發送密碼。總共有期望腳本不能正確發送密碼
- test.sh 3個文件
- test1.sh
- test.exp來
這裏是代碼:
test.sh(返回需要連接mysql數據庫的密碼)
grep hibernate.connection.password /opt/cisco/cpam/properties/vx.hibernate.properties | sed 's/hibernate.connection.password=//g'
test1.sh(需要被excecuted MySQL命令)
mysql -u cpam -p --protocol=tcp vxdb < /opt/cisco/cpam/import/MySQL_Views.sql
(即在執行MySQL的命令發送密碼expect腳本)test.exp來
set password [exec ./test.sh]
exec ./test1.sh
expect "Enter password: "
send "$password\r"
expect eof
運行expect test.exp的結果是我只看到提示符:
Enter password:
任何專家都可以幫我看看發生了什麼問題嗎?這肯定意味着test1.sh已經成功運行了,並且我也嘗試了很多次,包括使用靜態密碼。仍然只是提示。
非常感謝!
我感覺非常愚蠢..謝謝 – Tony