1
我試圖捕獲unix中程序的輸出,並將其用作期望腳本中的變量。當我excecute程序,我會得到這樣的事情:Unix-Expect:將命令的輸出捕獲爲期望變量
[[email protected]]# ./passwdgenerator
1234*&^^[[email protected]]#
正如你所看到的,「1234 * & ^^」是我想捕捉並放入expect腳本的密碼:
set user user1
set password [open ./passwdgenerator]
spawn ssh [email protected]
expect "password:"
send "$password\r"
顯然它目前不工作,只是想知道我應該如何寫這個。曾經在txt文件上試過這個,工作過。但是當它是程序輸出時,出於安全原因,我們不希望在文本文件中存儲密碼,所以它不起作用。任何專家都可以幫我一把嗎?非常感謝。!
嘗試'發送 「$密碼」'或(也許)'發送 「$密碼\ n」' –