/ usr / bin / expect内联多行命令

时间:2017-11-24 10:37:01

标签: shell command-line command expect

我在文件sign.sh中有此命令:

sudo openssl << EOF
engine dynamic ###long line here###
ca -engine pkcs11 ###long line here###
EOF

我在/usr/bin/expect中使用了这个

#!/usr/bin/expect

set timeout 10

spawn "sign.sh"

expect "Enter PKCS#11 key PIN for SIGN key:" { send "pass_here\r" }

interact

这很有效。但是,我需要将spawn "sign.sh"替换为spawn sudo openssl << EOF... etc

来“整理”这一行

我如何让它工作?

1 个答案:

答案 0 :(得分:1)

试试这样:

set script "
sudo openssl << EOF
engine dynamic ...
ca -engine pkcs11 ...
EOF
"

spawn bash -c $script