Lost Newbie

Brian Warner warner at lothar.com
Sat Sep 26 00:33:47 CEST 1998


wk at isil.d.shuttle.de (Werner Koch) writes:
> 
> ./gpg -r -e -o /pathtosillyfile/secret.txt /pathtosillyfile/test.txt
> 
> 
> It is not possible to mix options and arguments.

My two cents on what this means:

If you do a "gpg --help", you will get two separate lists. The first is a list
of commands. The second is a list of options. Whenever you run GPG, you *must*
pick exactly one command (**with one exception, see below). You *may* pick one
or more options.  The command must, in general, come at the end of the
argument list, after all the options. If the command takes a file (all the
basic ones do), that the filename comes at the very end. So the basic way to
run gpg is:

 gpg [--option something] [--option2] [--option3 something] --command file

Some options take arguments, for example the --output option (which can be
abbreviated -o) is an option which takes a filename. The option's argument
must follow immediately after the option itself: otherwise gpg doesn't know
which option the argument is supposed to go with. As an option, --output and
its filename must come before the command. The --remote-user (-r) option takes
a name or keyid to encrypt the message to, which must come right after the -r
argument.  The --encrypt (or -e) command comes after all the options, followed
by the file you wish to encrypt. So use:

 gpg -r alice -o secret.txt -e test.txt

If you write the options out in full, it is easier to read:

 gpg --remote-user alice --output secret.txt --encrypt test.txt

If you're saving it in a file called ".txt" then you'd probably expect to see
ascii-armored text in there, so you need to add the --armor (-a) option,
which doesn't take any arguments:

 gpg --armor --remote-user alice --output secret.txt --encrypt test.txt

If you imagine square brackets around the optional parts, it becomes a bit
clearer:

 gpg [--armor] [--remote-user alice] [--output secret.txt] --encrypt test.txt

The optional parts can be rearranged any way you want:

 gpg --output secret.txt --remote-user alice --armor --encrypt test.txt



** the exception: signing and encrypting at the same time. Use

 gpg [--options] --sign --encrypt foo.txt


hope this helps,
 -Brian
  warner at lothar.com




More information about the Gnupg-devel mailing list