Search code examples
command-linegnupg

Why is file I'm saving gpg --verify's output to staying empty?


When I run gpg --version > Desktop\op.txt command in command prompt, it creates an op.txt file on desktop with contents of the gpg version.

But when I run gpg --verify path\of\.asc\file > Desktop\op.txt, It creates a blank op.txt file on Desktop.

Output of gpg --verify path\of\.asc\file is

gpg: Signature made 06/16/14 20:34:29 India Standard Time using RSA key ID 7590DAFD
gpg: Good signature from "user"
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx

I was expecting this output in op.txt, but op.txt is blank.

Why it's not working?


Solution

  • GnuPG prints (at least some of) this output to stderr, not stdout. Redirect stderr to stdout using 2>&1:

    gpg --verify path\of\.asc\file 2>&1 > Desktop\op.txt