我已经创建了一个脚本,它将使用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