Automating the generation of master keys
Werner Koch
wk at gnupg.org
Wed Jun 1 19:46:36 CEST 2016
On Wed, 1 Jun 2016 12:47, dashohoxha at gmail.com said:
> I do it in batch mode like this:
> - https://github.com/dashohoxha/egpg/blob/gnupg-2.0/src/cmd/key/gen.sh#L42
Take care:
--8<---------------cut here---------------start------------->8---
local commands="addkey|4|4096|1m|addkey|6|4096|1m|save"
commands=$(echo "$commands" | tr '|' "\n")
script -c "gpg --batch --command-fd=0 --edit-key $GPG_KEY <<< \"$commands\"" /dev/null >/dev/null
while [[ -n $(ps ax | grep -e '--edit-key' | grep -v grep) ]]; do sleep 0.5; done
--8<---------------cut here---------------end--------------->8---
You can't use gpg this way - it does only work with a certain version
and build if GnuPG. Canned commands too fragile to use - you need to
process the output of --status-fd and act accordingly.
ps ax | grep -e '--edit-key' | grep -v grep
does not work either because you assume that there is only one gpg
command running (actually any process with a string '--edit-key').
BTW, Unix people use this trick to avoid the inverse grep:
grep -e '--edit-ke[y]'
Shalom-Salam,
Werner
--
Die Gedanken sind frei. Ausnahmen regelt ein Bundesgesetz.
/* EFH in Erkrath: https://alt-hochdahl.de/haus */
More information about the Gnupg-users
mailing list