当 bash 脚本提示输入“ ”时,我想使用“ expect
”自动输入“ ”键。<Enter>
Country Name (2 letter code) [US]:
预期如下:
/usr/bin/expect << EOF
set timeout -1
spawn /bin/bash /path/to/generate_openssl_certificate.sh
expect {
"Country Name (2 letter code) [US]:" {send "\r" ; exp_continue}
}
EOF
错误如下:
spawn /bin/bash /path/to/generate_openssl_certificate.sh
invalid command name "US"
while executing
"US"
invoked from within
"expect {
"Country Name (2 letter code) [US]:" {send "\r" ; exp_continue}
}"
当我尝试使用“ -re
”匹配字符串时,它与字符串“ Country Name (2 letter code) [US]:
”不匹配:
expect {
-re "Country Name \(2 letter code\) \[US\]:" {send "\r" ; exp_continue}
}
这是输出,屏幕正在等待“ <Enter>
”键继续:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [US]:
Country Name (2 letter code) [US]:
不使用“ ”,如何匹配“ -re
”?如何使用“ Country Name (2 letter code) [US]:
”匹配“ -re
”?