我在名为短语的文件中有密码短语,该短语保存在本地系统上:OXyqRC694pvKQ1FNfIYZQOKS
加密了我的密码: 回显“ ITSMYPASSWORD” | openssl enc -aes-128-cbc -a -salt -pass pass:OXyqRC694pvKQ1FNfIYZQOKS
在Expect脚本中,我试图在执行scp之前对密码进行解密,但是在解密密码时出现“错误的解密”错误
#!/usr/bin/expect
set upassword [lindex $argv 0]
set oF [open "phrase" r]
set dpassword [read $oF]
puts $upassword
puts $dpassword
puts "echo $upassword | openssl enc -aes-128-cbc -a -d -salt -pass pass:$dpassword"
#if i execute ouput of above line in shell, i am able to decrypt the password,
# but below exec command doesnot not work.
exec echo $upassword | openssl enc -aes-128-cbc -a -d -salt -pass pass:$dpassword
我该如何解决?
答案 0 :(得分:1)
在Tcl中,read
command将包含结束文件的换行符。试试这个:
<<
此外,exec
command具有exec openssl enc -aes-128-cbc -a -d -salt -pass pass:$dpassword << $upassword
重定向,可将字符串发送到命令的stdin:
{{1}}