#!/usr/bin/expect spawn gpgsm --gen-key --pinentry-mode=loopback -o encr.crt expect "Your selection?" send -- "1\r" expect "What keysize do you want? (3072)" send -- "2048\r" expect "Possible actions for a RSA key:" send -- "3\r" expect "Enter the X.509 subject name:" send -- "CN=Encryption key for canokey,O=example,C=DE\r" expect "Enter email addresses (end with an empty line):" send -- "test@example.org\r\r" expect "Enter DNS names (optional; end with an empty line):" send -- "\r" expect "Enter URIs (optional; end with an empty line):" send -- "\r" expect "Create self-signed certificate? (y/N)" send -- "y\r" expect "Proceed with creation? (y/N)" send -- "y\r" expect eof