I’m trying to automate JKS (Java Keystore) and CSR file generation via the keytool command (the java_cert module doesn’t do this, IIUC).The command, and the first 3 prompts are the following. Note that the third prompt is multi-lined.
$ keytool -genkey -alias tomcat -keyalg RSA -sigalg SHA1withRSA -keysize 2048 -keystore keystore.jks Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]:
Expect is just looking a a stream of bytes, when it sees a string it will "type" the response.
So in this case you only need to check for the string [Unknown]:
Since is special character in regex you need to escape them
"\[Unknown\]: ": "myserver.domain.com"
You could also leave out the quotes, the colon and the space, this will also work
[WARNING]: While constructing a mapping from /home/scscm_builder/copy- expect.yml, line 20, column 9, found a duplicate dict key (\[Unknown\]). Using last defined value only.
I need to somehow include part of each prompt in the regex?
Thanks Kai. Your comment “Expect is just looking a a stream of bytes” gave me the idea to just look for a “string of bytes” that’s present in each prompt. The following now works.