#!/usr/bin/expect spawn gpg --full-generate-key expect "Your selection?" send -- "14\r" expect "Your selection?" send -- "3\r" expect "Key is valid for? (0)" send -- "\r" expect "Is this correct? (y/N)" send -- "y\r" expect "Real name:" send -- "PIV Test\r" expect "Email address:" send -- "test@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 spawn gpg --edit-key test@example.org expect "gpg>" send -- "addkey\r" expect "Your selection?" send -- "14\r" expect "Your selection?" send -- "4\r" expect "Key is valid for? (0)" send -- "\r" expect "Is this correct? (y/N)" send -- "y\r" expect "Really create? (y/N)" send -- "y\r" expect "gpg>" send -- "save\r" expect eof