Per Eriksson Per Eriksson - 17 days ago 9
Bash Question

/usr/bin/expect inline multiline command

I have this command in a file

sign.sh
:

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


I have used this in
/usr/bin/expect
like this

#!/usr/bin/expect

set timeout 10

spawn "sign.sh"

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

interact


This works. But I need to "one line" this whole thing by replacing
spawn "sign.sh"
with
spawn sudo openssl << EOF... etc


How do I get that to work?

Answer Source

Try like this:

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

spawn bash -c $script