#!/usr/bin/expect set grip1 [lindex $argv 0] spawn gpg --expert --full-generate-key expect "Your selection?" send -- "13\r" expect "Enter the keygrip:" send -- "$grip1\r" expect "Your selection?" send -- "e\r" expect "Your selection?" send -- "q\r" expect "Key is valid for? (0)" send -- "\r" expect "Is this correct? (y/N)" send -- "y\r" expect "Real name:" send -- "PKCS11 Test\r" expect "Email address:" send -- "pkcs11@example.org\r" expect "Comment:" send -- "\r" expect "Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?" send -- "o\r" expect eof