pat*_*k h 7 bash openssl pipe less-unix
我想做点什么
openssl enc -d -aes256 -in somefile | less
Run Code Online (Sandbox Code Playgroud)
openssl
需要密码来自stdin
.这less
涉及到所有搞砸了.
有没有办法从交互式命令(如openssl
要求输入密码)获取输出并将输出管道输入less
?
或者是否有更好的技术使用bash脚本?
你可以试试这个:
echo 'mypassword' | openssl enc -d -aes256 -in somefile | less
Run Code Online (Sandbox Code Playgroud)
但这看起来并不安全。
我没有尝试过以openssl
这种方式运行,但如果它太冗长并且之前的代码不起作用,那么您可以随时尝试使用Expect。这是一个例子:
expect -c '
spawn yourscript
expect "Please enter your password:"
send "$PASSWORD"
'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
940 次 |
最近记录: |