简体   繁体   中英

/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?

Try like this:

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

spawn bash -c $script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM