我已經創建了一個腳本,它將使用SFTP連接到服務器。 爲了避免將密碼作爲純文本輸入到腳本中,我打算將它放在一個以base64編碼的文件中。 我可以從文件中讀取沒有問題。但我不知道如何用Expect解碼base64。 因此,目前,腳本讀取文件並將密碼(直接)放入腳本中。如何解碼它? 如果有一種很好的方法來做這樣的事情,我已經準備好將所有腳本移回Shell/bash。Expect腳本:從文件中讀取Base64密碼
謝謝。下面的代碼:
#!/usr/bin/expect
set myPassword [open "sftp_auth.cfg" r]
set data [read $myPassword]
spawn sftp [email protected]
expect "*assword:"
send "$data\n"
expect "sftp>"
send "cd /repository\n"
expect "sftp>"
send "get Example.sh /home/User/Example2.sh\n"
expect "sftp>"
send "exit\n"
interact
爲那些尋求如何從文件中的一個期望腳本讀取用戶名和密碼:https://開頭WWW。 linuxquestions.org/questions/programming-9/expect-read-passphrase-from-a-file-287216/ – lesmana