Mailing List Archive

Re: Parsing the output of --list-keys
Jonas,
I'm not sure if this is exactly what your after.. but I think it might help,
or at least make the output easier to parse... try:

gpg --list-keys --with-colons

my key lists like this:
[tnelson@borneo tnelson]$ gpg --list-keys --with-colons tnelson@techie.com
pub:u:1024:17:51FF9A17136C5B87:1999-04-24::59:-:Tony Nelson <tnelson@techie.com>:
uid:u::::::::Tony Nelson <tnelson@conceptech.com>:
uid:u::::::::Tony Nelson <tnelson@partysite.com>:
sub:u:2048:16:9F67F69212171284:1999-04-24::59::

Which contains all three of my e-mail addresses in a 'easy to parse' foramt..

Hope this helps
Tony

On Thu, Jan 13, 2000 at 08:34:39PM +0100, Jonas Steverud wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
> I work on a set of elisp functions that will syncronize GnuPG's public
> keyring and the BBDB's pgp-mail field (see mc-bbdb.el and bbdb-pgp.el,
> don't know where you can get the latter but the former is available
> from <URL:http://www.kaidea.freeserve.co.uk/elisp.html>).
>
> My question is; is there an easy way of getting a list of who is in
> the keyring and his email addresses?
>
> What I want is something like:
> "John A" email1@somewhere email2@somewhere
> "Anne" a@b.c d@.e.f
>
> It would be much easier for me to parse then the current output of
> - --list-keys. I assume I can write something in awk but I though I
> might ask first since I'm bored of inventing the wheel over and over
> again.
>
> Clear as mud?
>
> - --
> ( GPG/PGP key @ www.dtek.chalmers.se/~d4jonas/ ! Wei Wu Wei )
> ( U2MoL, Roleplaying, LaTeX, Emacs/Gnus, SCWM, etc. ! To Do Without Do )
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.0 (SunOS)
> Comment: Processed by Mailcrypt and Gnu Privacy Guard <www.gnupg.org>
>
> iD8DBQE4fijOYFmxFYdMVIkRAgJOAJ4/smX7RxUEGarTnviGl50THtKMywCcDhDj
> HqHm91pVAjK3UVMogbSeJNs=
> =eGJW
> -----END PGP SIGNATURE-----
>

--
Tony Nelson Standard Disclaimers Apply
Re: Parsing the output of --list-keys [ In reply to ]
On Mon, 17 Jan 2000, Jonas Steverud wrote:

> <tnelson@conceptech.com>" is not hard since the number of characters
> from the left marging is 31 (i.e. (forward-char 31)). The problem is
> to get "Tony Nelson", "(optional comment)" and
> "tnelson@conceptech.com".

What you should do here is RFC822 address parsing. Doing it with r.e.
is not trivial. However, if this user ID is GnuPG generated it is
easy to get all three parts:

1. part: Collect everything up to (but excluding) the first
opening parenthesis or the first left angle bracket.
2. part: Only if you stopped at a parenthesis, collect everthing up
to the closing parenthesis. Although it is not yet
allowed, you might want to keep a counter of opening
closing parenthesis.
3. part: Only if you have a left angle bracket, collect everything
up to the right angle bracket.

It should be easy to construct a sed,awk,perl r.e. for this.

> I have found a way of doing this with regexps so the problem is
> solved, but if --with-colons had put colons between the wanted parts

No that is not possible.


--
Werner Koch at guug.de www.gnupg.org keyid 621CC013

Boycott Amazon! - http://www.gnu.org/philosophy/amazon.html
Re: Parsing the output of --list-keys [ In reply to ]
>What you should do here is RFC822 address parsing. Doing it with r.e.
>is not trivial. However, if this user ID is GnuPG generated it is
>easy to get all three parts:
>
> 1. part: Collect everything up to (but excluding) the first
> opening parenthesis or the first left angle bracket.
> 2. part: Only if you stopped at a parenthesis, collect everthing up
> to the closing parenthesis. Although it is not yet
> allowed, you might want to keep a counter of opening
> closing parenthesis.
> 3. part: Only if you have a left angle bracket, collect everything
> up to the right angle bracket.
>
>It should be easy to construct a sed,awk,perl r.e. for this.

If someone does write this, please drop it by my way and I'll add it
to the Regex Library:

http://www.smartnetworks.net/~rosso/regex/

...Ross...
|
|| rosso@bad-seed.org Personal website (New Address):
||| <http://www.smartnetworks.net/~rosso/>
|||| The Cave Inn is Closing, grab what you want:
||||| http://www.bad-seed.org/caveinn/ @--'-,--