I'm writing a bash script to create self-signed certificate.
The script works well until I have to sign the certificate. Indeed, i can't get my expect command to match the received string.
Here is the string my terminal returns :
Sign the certificate? [y/n]:
And here are my commands :
/usr/bin/expect <<EOD
spawn sudo openssl ca -config CA/ca.cnf -policy policy_anything -out CA/newcerts/webserver.cert -infiles CA/certrequests/webserver.csr
expect {Enter pass phrase for ./CA/private/cakey.pem:} {send "${PEMpassword}\n"}
expect -re {Sign the certificate? [^:]*:} {send "y\n"}
expect -re {1 out of 1 certificate requests certified, commit? [^:]*:} {send "y\n"}
expect eof
EOD
I'm not very familiar with expect nor regex but "[^:]*" worked for me until now for similar strings.
I have unsuccessfully tried those :
[?*]
\*
?:
[y/n]
\[y/n\]
"[y/n]"
[\w/\w]
[w+]
[\w+]
Thanks in advance for your suggestions !